what is docker run -it flag?
docker run -it ubuntu:xenial /bin/bash
starts the container in the interactive mode (hence -it
flag) that allows you to interact with /bin/bash
of the container. That means now you will have bash
session inside the container, so you can ls
, mkdir
, or do any bash command inside the container.The key here is the word "interactive". If you omit the flag, the container still executes
/bin/bash
but exits immediately. With the flag, the container executes /bin/bash
then patiently waits for your input.