Start your first Docker Container
In this lecture you are going to start your first container, step by step. Iāll explain all the flags and everything that happens in depth.
Video
Commands
docker run -it ubuntu /bin/bash
runs the container and attaches to stdin, the standard input, where the /bin/bash processs is opened
- Flags:
-it
: interactive flag
ls
file system from linux
Now open a second terminal/console:
docker ps
Start this from a second terminal which lists the currently running container
exit
Exits the container and the linux file system again
docker ps
Lists the currently running containers, which is empty
docker ps -a
Lists all containers, the running ones and the empty ones
docker start container_identifier
We can restart a container that was previously running
docker ps
The container comes up as running again. Creation date != running date
docker attach container_identifier
We can re-attach to the container
docker stop container_identifier
stop the running container
docker ps
The container is not running anymore
docker ps -a
The container is still in our system
docker rm container_identifier
Clean up: Remove the container
docker ps -a
And the list is empty again