Start a Docker Container with Exited Status

In this guide, we want to show you how to Start a Docker Container with Exited Status. A Docker Container is a model of a Docker image that can do different tasks inside the container. The Docker Container has different states or statuses. Once you want to check your Docker container is up and running, you will get the status of it. One of these statuses is Exited. When you get this status, you will not be able to run the container with the Docker Exec command. So what should we do? You can proceed to the following steps to see how you can do it.

Quickly Start a Docker Container with Exited Status

In this guide, we will show you an example of the exited status of a container and teach you how you can start it. To do this, follow the steps below.

Note: To get a Docker installation and configuration guide, you can visit the Docker Tutorials.

Step 1 – Check the Docker Container State

First, we check our docker container status by using the command below:

docker ps -a

Example Output:

Docker container with exited status

As you can see in the above example, we have an exited status for our container. Let’s see the reasons that caused this to happen.

Step 2 – Why Do You Get Docker Exited Status?

Once the process inside the container terminates, you will get the Exited status. In this case, no CPU and memory are consumed by the container. Many reasons may cause this to happen including:

  • The process inside the container was completed, and so it exited.
  • The process inside the container encountered an exception while running.
  • A container is intentionally stopped using the docker stop command.
  • No interactive terminal was set to a container running bash.

As we said, in this case, the container can not be accessed with the Docker Exec command.

Step 3 – Start an Exited State Container

At this point, you can easily use the docker start command with your container name to start it. For example, our container name is sql1, to start it, we use the command below:

docker start sql1

Again check the container status:

docker ps -a

We should see that our container is up and running:

Up status docker container

Alternatively, you can use the following command:

docker start  `docker ps -q -l`

This command will only get the latest docker container.

To start all the containers, you can use the following command:

docker start  `docker ps -q -a`

That’s it, now you can run the docker exec command to access your container.

For more information, you can visit the official Documentation page.

Conclusion

At this point, you have learned to Start a Docker Container with Exited Status. As you saw, with exited status you can not access the container with the docker exec command, you should start your container. Hope you enjoy it.

Also, you may like to read the following articles:

MS SQL Server Setup with Docker on RHEL 9

Install MySQL in Docker Container on Debian 12

Install Docker Desktop on Windows

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular