Every docker run command creates a container on your system. When you exit the container (and it is no longer running) it is still there on disk and can be seen with
docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ea520a35da1f jvzoggel/kafka "/bin/bash" 2 minutes ago Exited (0) 2 minutes ago kafka1 46067fe01dc4 jvzoggel/kafka "/bin/bash" 3 minutes ago Exited (0) 2 minutes ago kafka2 0b7bcb382e65 jvzoggel/kafka "/bin/bash" 3 minutes ago Exited (0) 3 minutes ago kafka3
The containers that are not running will not consume any system resources except disk space, but it is usually good to clean up after yourself so ..
Automatically clean-up after yourself
The Docker documentation describes how to automatically clean up the container and remove the file system when the container exits:
–rm=false: Automatically remove the container when it exits (incompatible with -d)
The above shows that by default containers are not removed, so by adding –rm=true or just the short-hand –rm will do the trick:
docker run -i -t --rm jvzoggel/kafka /bin/bash
When you exit from the container it will be automatically removed from disc.
Manually clean-up your stuff
Another method (all credits: Guillaume J. Charmes) is the command:
docker rm `docker ps --no-trunc -aq`
which will remove all containers in a elegant way