0

When testing with docker, I don't see any functional differences between the following two commands:

docker run --rm -it ubuntu:18.04 bash docker run -it ubuntu:18.04 bash

By differences, I mean that the docker container started without the '--rm' doesn't show up in 'docker container ls' or 'docker container ps' after I exit the terminal. Is it necessary to use the --rm option when attaching to an terminal with the -it option? Is there a corner case that I'm not understanding where the --rm is required to clean up the container?

Apologies if this has been asked before. Seems like a simple enough question, but I had a tough time tracking down a related post. Thanks in advance for the help!

William
  • 79
  • 2
  • 9
  • Try `docker ps -a`, which will also show stopped containers. The form without `--rm` should be leaving them behind. – David Maze Oct 26 '21 at 21:11
  • @DavidMaze Ah. This makes a lot more sense now. Thanks! You're correct that the exited containers still remain. --rm is very much necessary. – William Oct 26 '21 at 22:37

0 Answers0