This article will describe the different possible states of the Docker container.
What are the States of a Docker Container?
The possible states of the Docker container are as follows:
Created State
When the new container is built or created, it enters in the “created” state. The “created” state refers to a container that has been created/built but is not in the running state. It means that the container exists on the device but it is not active now.
Command
The command for creating a Docker container is given-below:
Running State
The “running” state indicates that the container is currently executing without any issues. The “docker ps” command is used to check the running state of the container.
Command
To run the Docker container, utilize the “docker start” command along with the particular container name:
Restarting State
The “restarting” state refers to stopping the container and starting again. It resets the container’s current state.
Command
Use the “git restart” command along with the desired container name that needs to be restarted:
Paused State
The “paused” state indicates that the container is temporarily stopped and is in the frozen state. It permits users to stop the execution of the container without actually stopping it so that its operations can be resumed from where they left off.
Command
To pause the particular container, run the below-listed command:
Exited State
The “exited” state of a container refers to the state of the container when it has stopped running. When the container finishes its task, it stops automatically and enters the “exited” state. Users can also stop the container manually using the command.
Command
Utilize the “docker stop” command with the particular container name to stop it:
Dead State
The “dead” state refers to the state when the container is no longer running and cannot be restarted. This can happen for various reasons, such as if the container has crashed or if it has been manually stopped and removed. A dead container is no longer running and cannot be started or restarted.
Conclusion
The possible states of a Docker container are created, running, restarting, paused, exited, and dead. The “created” state is the state when the container has been built but not active/started yet. The “running” state indicates that the container is currently executing. The “restarting” state refers to stopping the container and starting again. The “paused” state indicates that the container is temporarily stopped. The “exited” state of a container refers to the state of the container when it has stopped running. The “dead” state refers to the state when the container is no longer running and cannot be restarted.