Get the App
SLTechnology News&Howtos  ›  Servers  › 

The docker internal container automatically restarts the configuration.

Shulou Source: shulou.com Published: 2022-06-02 15:08:00 10月04日 Update

1. The parameter restart=always is not added when the container is created, which results in that the container fails to start automatically when Docker is restarted.

An example of docker container update-restart=always container name operation is as follows: [root@localhost mnt] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES46cdfc60b7a6 nginx "nginx-g 'daemon..." About a minute ago Up 42 seconds 80/tcp n379d55a734c26 nginx "nginx-g 'daemon..." About a minute ago Up 42 seconds 80/tcp n2f7b2206c019d nginx "nginx-g 'daemon..." About a minute ago Up 46 seconds 80/tcp N1 [root@localhost mnt] # docker container update-- restart=always n1n1 [root@localhost mnt] # systemctl restart docker [root@localhost mnt] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES46cdfc60b7a6 nginx "nginx-g' Daemon... "2 minutes ago Exited (0) 5 seconds ago n379d55a734c26 nginx" nginx-g'daemon... "2 minutes ago Exited (0) 5 seconds ago n2f7b2206c019d nginx" nginx-g 'daemon... "2 minutes ago Up 2 seconds 80/tcp N1

2.docker-compose shuts down or restarts docker while restarting the configuration of container restart always

As we all know, if you start using docker, you need to add-restart=always to achieve this function, while if you use docker-compose, you can add restart: always to the relevant service configuration.

Version: '2'services: database: build:. / mysql/ command: mysqld-- user=root-- verbose restart: always environment: MYSQL_DATABASE: "web_level3_sqli" MYSQL_USER: "web_level3_sqli" MYSQL_PASSWORD: "thisisasecurepassword123" MYSQL_ROOT_PASSWORD: "root" MYSQL_ALLOW_EMPTY_PASSWORD: "yes" web: build:. / www/ Restart: always ports:-"12000 www/src:/var/www/html links 80" volumes: -. / www/src:/var/www/html links:-database

Tags: Containers configurations well known functions parameters at the same time names consequences instances service configurations services Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information MySQL Apple Xiaomi