When you run a docker image and a container is created, when the container exists docker will not remove the container that existed by default, let's see this by creating multiple containers from fedora image,
Container 1:% docker run fedora echo hello1
hello1
Container 2:
% docker run fedora echo hello2
hello2
Container 3:
% docker run fedora echo hello3
hello3
Now, if I do a docker ps -a to see the list of all containers, I see that there are 3 containers that exited but have not been removed and utilizing memory.
% docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e9072f3eff69 fedora "echo hello3" 9 seconds ago Exited (0) 9 seconds ago thirsty_almeida
21abcc335be3 fedora "echo hello2" 11 seconds ago Exited (0) 11 seconds ago interesting_turing
0c0ba20b0018 fedora "echo hello1" 57 seconds ago Exited (0) 56 seconds ago cool_robinson
If you wish to remove the created container when the docker run command completes, you should add --rm option to the docker run command.
Example: Docker run with --rm option:% docker run --rm fedora echo hello4
hello4

Have Questions? Post them here!
- How to docker remove a container when it exits
- Install Python on Alpine Linux - Docker
- How to Rename Docker Image with none TAG and REPOSITORY?
- Remove all stopped containers in Docker using prune command
- [Fix] Docker Error response from daemon: manifest for :latest not found: manifest unknown
- [fix] Error response from daemon: conflict unable to remove repository reference ubuntu container is using its referenced image
- [Docker] Install Python3 on Alpine Linux
- Unable to find image docker latest locally
- How to Stop/Cancel/kill docker image pull
- How to know the Docker Engine Version
- [fix] Docker: OCI runtime exec failed unable to start container process
- [Solution] Alpine Docker apt-get: not found
- Install and Run Cassandra on Docker Desktop
- Install node on Alpine Linux Docker
- How to Copy files from Docker Container to Host System
- Install the minimal Linux on Docker (only 5 mb Alpine Linux)
- How to stop and start a docker container
- Docker - Error response from daemon: You cannot remove a running container
- Open Docker Desktop from macOS Terminal
- How to check installed docker version command
- How to know the Docker Sandbox ID of a Container Network?
- [fix] docker: Error response from daemon: dial unix docker.raw.sock: connect: no such file or directory.
- [Docker] Install Git on Alpine Linux
- Docker MySQL Compose File with Volume Example
- [fix] Docker: Alpine Linux - /bin/sh: bash: not found
- Fix: Cannot contact reCAPTCHA. Check your connection and try again. - Google
- Java SE JDBC with Prepared Statement Parameterized Select Example - Java
- Comparator with Lambda Examples - Java
- Android read text file from internal storage - Android
- The Date Command and its usage [Linux - Unix - macOS] - Linux
- Are Windows Notepad files recoverable? - NotepadPlusPlus
- TextEdit save file with txt extension - MacOS
- Android Studio : Build Tools 23.0.0 rc1 is deprecated - Android-Studio