Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The docker internal container automatically restarts the configuration.

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report