| by Arround The Web | No comments

Docker restart Container

On the Docker platform, all processing of projects is done in Docker containers. Docker containers are used to manage and run projects. These containers are processed by various commands, and “docker start” and “docker restart” are one of the most used command line utilities to start or run Docker containers.

This blog will demonstrate how to restart a Docker container.

How to Restart Container Using “docker restart” Command?

The docker restart command is mostly used to start the stopped containers. To restart the container, utilize the “docker restart <container-id>” command.

Go through the provided instructions to restart the Docker container.

Step 1: Create Docker Container

First, create a fresh container from the Docker image by utilizing the provided command. Here:

  • -i” is used to create a container in interactive mode.
  • -p” is used to specify the port where the container will execute.
  • –name” is utilized to define the container name:
> docker container create -i -p 8080:8080 --name docker-container dockerimage

Step 2: Start Container

After creating a container, start the container through the “docker start <container-name>” command:

> docker start docker-container

Now, navigate to the specified port on the browser. In our scenario, we have navigated the “http://localhost:8080” URL on the browser:

Step 3: Stop Docker Container

To stop the container, users can utilize the “docker stop <container-name>” command:

> docker stop docker-container

Step 4: List Docker Container

List all the docker containers using the “docker ps” command. After that, note the container if you want to restart. Here, the “-a” option is used to list all containers:

> docker ps -a

Step 5: Restart Docker Container

Next, restart the stopped container with the help of the “docker restart <container-id>” command:

> docker restart bdfad87625eb

Alternatively, you can also utilize the container name with the “docker restart” command to restart the container by name:

> docker restart docker-container

Here, you can see we successfully restart the container:

Note: The “docker restart” is a shorthand command of “docker container restart”. Users can also execute the “docker container restart” command to restart containers:

> docker container restart docker-container

Conclusion

The “docker restart” is a shorthand command of “docker container restart” that is used to restart or start the Docker containers. To restart the Docker containers, the user can utilize the “docker start” or “docker restart <container-name>” command. This write-up has elaborated on the “docker restart” command and how to restart the container.

Share Button

Source: linuxhint.com

Leave a Reply