Home > Operation and Maintenance > Docker > Will docker automatically restart?

Will docker automatically restart?

藏色散人
Release: 2021-12-30 11:39:49
Original
5341 people have browsed it

Docker will automatically restart. The way to achieve this is to add the parameter "--restart=always" when starting the container to achieve automatic restart.

Will docker automatically restart?

The operating environment of this article: ubuntu 18.04 system, Docker version 20.10.11, Dell G3 computer.

Will docker automatically restart?

docker will automatically restart.

How to make Docker containers automatically restart:

Problem

System restart, Docker restart, etc. will cause the running container to stop running, and you have to Start the container again, but this is really troublesome. In fact, Docker provides an automatic restart mechanism.

Solution

When starting the container, just add the parameter --restart=always to achieve automatic restart, as follows:

$ docker run --restart=always
Copy after login

The restart strategy provided by Docker is not only always, but also as follows:

Will docker automatically restart?

unless-stopped usage is as follows:

$ docker run -d --restart unless-stopped redis
Copy after login

For containers that are already running

For containers that are already running, and the --restart parameter is not added when starting, you can increase it through the update command:

$ docker update --restart=always xxx
Copy after login

For the number of on-failures

For the policy on -failure can increase the number of times to prevent unlimited restarts:

$ sudo docker run --restart=on-failure:10 redis
Copy after login

Recommended learning: "docker video tutorial"

The above is the detailed content of Will docker automatically restart?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template