Docker run exited container – How to fix the error?
Are you looking for why the docker run exited the container?
We can help you to start an exited container with a docker start and docker attach.
At Bobcares, we often fix Docker errors, as a part of our Docker Hosting Support.
Today, let’s see why docker run exited containers and how our Support Engineers fix this error.
What does docker run do?
Docker is a container technology for provisioning applications quickly based on docker images.
A Dockerfile contains the specification of a docker image. To create a docker image from the Dockerfile we use the command docker run.
So, the docker run is a command to launch Docker containers.
Why containers exit on docker run?
Containers exit on docker run due to many reasons. And mostly this can happen due to improper setup of Dockerfile.
As we have said, docker run command launch docker container by reading Dockerfile. Any error in this can exit the container.
So, our Support Engineers check the Dockerfile and correct it.
For instance, changing the COPY command to AND command can fix this error. Later we need to start this exited container.
How to start this exited Docker container?
Now let’s check out how to start the exited containers. We can do this in two ways.
Start exited Docker container using container ID
Initially, we need to list the containers. The command to list them is,
Whereas to list exited containers, our Support Engineers use the command,
docker ps -f "status=exited"
From here we can obtain the container ID. Then to start the container we use the command,
docker start <container ID>
Later to attach to this container we use the command,
docker attach <container ID>
If the above command doesn’t work then we use the below command,
docker start -a <container ID>
Here, -a option indicates attach. This starts and attaches the container.
Start the Docker container last created and exited
Alternatively, if the container just exited we can easily start it in a single step. For this, we use the command,
`docker ps -q -l` replaces the container ID of the last created Docker container.
Additionally, we can also use options like -i to start the container in interactive mode.
[Need assistance in fixing Docker errors? – We can help you.]
So far, why docker run exited container. We also saw how our Support Engineers fixed this error and started an exited container.