In this tutorial I will tell you what are the possible states of docker container.
Here I am going to tell you about all possible states of docker container.
States of Docker Container
Created: If your docker container is newly created (docker create), you will see this state for your docker container. In this state, the container is not yet started.
Restarting: A container that is in the process of being restarted. So when you restart your docker container or container restarts itself due to a problem, you will see this state.
Docker has four different restart policies:
- The default is called no. With this policy, the Docker daemon will never try to restart your container (unless you tell it to manually).
- The second policy is on-failure. With this policy, the Docker daemon will try to restart container if any problem exists, that is, if any startup script returns a non-zero exit code.
- The third policy is always. With this policy, the Docker daemon will try restart container if:
- If there is any problem
- If you stop them manually
- The docker daemon was itself stopped and restarted
- The fourth policy is unless-stopped, where the Docker daemon will always try to restart container unless you stop them manually.
Running: A currently running container. Running is the main state you’ll see for container. It means it has started, and there is no problem detected with the container itself.
Paused: A container whose processes have been paused. If you temporarily stop your running Docker container via docker pause, this is what you’ll see until you unpause it.
Exited: A container that ran and completed. If your container has stopped because of a problem or you stopped your container manually, you will see your container in this state, depending on your restart policy as described above.
Dead: A container that the daemon tried and failed to stop (usually due to a busy device or resource used by the container).
How to check Docker Containers
You can verify the running containers using the following command:
$ docker ps
The above command only displays only currently running containers.
If you want to check all containers then you can execute the following command:
$ docker ps -a or $ docker ps -all
The output might be truncated for the above commands, so you can use –no-trunc with the above commands to prevent output truncating. For example, you can use:
$ docker ps --no-trunc
That’s all about possible states of docker containers.