docker-compose重启容器测试
容器准备
root@node2:~
root@node2:~
root@bab98093d91e:/
root@bab98093d91e:/
web1
root@bab98093d91e:/
exit
root@node2:~
root@node2:~
root@bab98093d91e:/
root@bab98093d91e:/
web2
root@bab98093d91e:/
exit
root@node2:~
启动测试
root@node2:~
services:
nginx:
image: nginx:web2
ports:
- "80:80"
nginx2:
image: nginx:web2
ports:
- "8080:80"
root@node2:~
[+] Running 2/2
✔ Container root-nginx-1 Started
✔ Container root-nginx2-1 Started
root@node2:~
web2
root@node2:~
web2
改变镜像测试
root@node2:~
services:
nginx:
image: nginx:web1
ports:
- "80:80"
nginx2:
image: nginx:web2
ports:
- "8080:80"
root@node2:~
root@node2:~
web2
root@node2:~
[+] Running 2/2
✔ Container root-nginx-1 Started
✔ Container root-nginx2-1 Running
root@node2:~
CONTAINER ID IMAGE COMMAND CREATED STATUS
a7e028aaf544 nginx:web2 "/docker-entrypoint.…" 7 minutes ago Up 6 minutes
8902b46d5c05 nginx:web2 "/docker-entrypoint.…" 12 minutes ago Up 12 minutes
改变配置测试
root@node2:~
server {
listen 8880;
server_name local;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
root@node2:~
services:
nginx:
image: nginx:web1
volumes:
- ./web.conf:/etc/nginx/conf.d/web.conf
ports:
- "80:80"
- "8880:8880"
nginx2:
image: nginx:web2
ports:
- "8080:80"
root@node2:~
[+] Running 2/2
✔ Container root-nginx2-1 Running
✔ Container root-nginx-1 Started
root@node2:~
web1
重启所有镜像–force-recreate
root@node2:~
[+] Running 2/2
✔ Container root-nginx2-1 Started
✔ Container root-nginx-1 Started