This blog will demonstrate the method to restart a Docker container that has been stopped.
What are the Steps to Restart a Docker Container that has been Stopped?
To restart a Docker container that has been stopped, the “docker start <container-name/ID>” command is used. To do so, follow the below-provided step-by-step instructions:
Step 1: View All Containers
First, display all the available containers and choose a particular container to stop it:
In the above output, all the containers can be seen. We have selected the “myCont” container that is running.
Step 2: Stop Running Container
Then, stop the selected running container using the “docker stop” command along with the container name:
This command has stopped the “myCont” container.
Step 3: Verify Stopped Container
Next, use the provided command to ensure that the selected container has been stopped:
The “myCont” container has been stopped successfully.
Step 4: Restart the Stopped Container
To restart the container that has been stopped, write out the “docker start” command along with the container name or ID:
Alternatively, the user can also use the desired container ID to restart it:
This command has restarted the stopped container.
Step 5: Verify Restarted Container
To verify whether the container has been restarted or not, execute the provided command:
As you can see the “myCont” container has been restarted successfully.
Bonus Tip: Restart the Running Container
To stop the container and start it again, use the “docker restart <container-name/ID” command:
The above command has stopped the “myCont” container and started it again.
Conclusion
To restart a Docker container that has been stopped, the “docker start ” command is used. Users can also use the “docker restart <container-name/ID” command to stop the container and start it again. This blog has demonstrated the method to restart a Docker container that has been stopped.