Restart Container in Docker

The problem of restart container in docker

In this post, we will learn how one can restart a container in docker. This happens while the container is running in docker but suddenly stops working. An example of the same is shown here. One person is running the following command to run their docker file.

 

 

docker run -d myimage /bin/bash -c "mycommand"

 

 

After some time the docker file stopped running after the completion of “mycommand”. Let’s understand some ways to restart the docker. 

 

 

Solution

To restart the docker when the initial command stops working one can follow the given solution. This mainly happens when the initial command finishes its execution. The command for the same is shown below:  

docker start container_name

In order to check the output of the above command, one needs to add -ai in the above command. An example for the same is shown below:

docker start -ai container_name

The docker restart container name command can be used to restart a running container, which is not the case in your instance, in my opinion.

First, docker ($) The reason users are not seeing your stopped container listed is because ps -a displays all containers, both running and stopped ones.

The second is that users can quickly restart a halted container:

 

 

$ docker start container_name

 

 

Also Read: rmarkdown figure auto-adjust HTML

 

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *