Feel free to experiment with these commands:
docker -v
: Version, install is OKdocker -h
: Read the helpdocker ps
: No running containerdocker image ls
: Are some image available on the systemdocker pull hello-world
: Pull from hubdocker image ls
: hello-world is available locally nowdocker run hello-world
: Understand what it is saying?- Visit
https://hub.docker.com
or usedocker search
to find images
docker run alpine
: Nothingdocker ps
: Nothingdocker ps -a
: Container exited after executing /bin/shwhoami
: Hosthostname
: Hostuname -a
: Hostdocker run --help
docker run -it --hostname "alpine-container" alpine
: Now something! Interactively, /bin/sh is executedwhoami
: I'm in the containerhostname
: I'm in the containeruname -a
: The container is on the hostps aux
: No OS is running / PID 1 is not init: but the bash!- Execute commands in the containers and explore fle system
- Show volatility:
echo "Servus! Bonjour! ¡Hola! Hello!" > hello.txt
- exit / ctrl-D / ctrl-P ctrl-Q
- Try common UN*X commands in your shell:
ls
,cd
,pwd
... Are some of them missing? Is it a bug or feature of containers? Of Alpine? - Going further: Use the apk package manager to find and install addition packages. How about man, python, htop, neofetch for example?
- Explore the filesystem around you. Can you see files from the host system?
- Create a file, for example via : echo "Servus! Bonjour! ¡Hola! Hello!" > hello.txt. Exit the container and start it again. Is the file still here?
- Would you dare executing
rm -rf /*
in the container. What happens? Exit the container and start it again? What happened?