I was trying to run ubuntu docker image in background. So I tried below command
sudo docker container run -d --name my-ubuntu-container ubuntu:latest
But this command do not run the container in background. In fact the status becomes "EXITED" on checking using
docker container ls -a
But if I add "-it" flag in above command. Then the container runs in background.
sudo docker container run -itd --name my-ubuntu-container ubuntu:latest
Now on checking in docker container ls -a
. We see the status now in "UP" and it runs in background.
Anyone can please advise why adding "-it" flag in above command along with "-d" runs the ubuntu docker image in background ?