Sometimes when working with Docker you just want to quickly start a container and interact with it through a shell. Fortunately this is easy to do. Here is an example of creating and running an Ubuntu container with a bash shell:

docker run -it --rm ubuntu /bin/bash

Here is the explanation of this command:
docker run – run a command in a Docker container
-t – allocate a psuedo tty (terminal)
-i – keep STDIN open in order to interact with the terminal
--rm – remove/delete the container once it exits (optional)
ubuntu – create the container from the latest Ubuntu image
/bin/bash – start a bash shell session

Leave a Reply

How to Start an Interactive Docker Container