您的位置:首页 > 娱乐 > 八卦 > 创意字体设计网站_教务系统门户网站_深圳建站公司_百度收录规则2022

创意字体设计网站_教务系统门户网站_深圳建站公司_百度收录规则2022

2025/4/18 16:13:08 来源:https://blog.csdn.net/weixin_60092693/article/details/145080953  浏览:    关键词:创意字体设计网站_教务系统门户网站_深圳建站公司_百度收录规则2022
创意字体设计网站_教务系统门户网站_深圳建站公司_百度收录规则2022

docker-compose重启容器测试

容器准备

root@node2:~# docker run -itd nginx
root@node2:~# docker exec -it bab bash
root@bab98093d91e:/# echo web1 >/usr/share/nginx/html/index.html
root@bab98093d91e:/# curl localhost
web1
root@bab98093d91e:/# exit
exit
root@node2:~# docker commit bab98093d91e nginx:web1root@node2:~# docker exec -it bab bash
root@bab98093d91e:/# echo web2 >/usr/share/nginx/html/index.html
root@bab98093d91e:/# curl localhost
web2
root@bab98093d91e:/# exit
exit
root@node2:~# docker commit bab98093d91e nginx:web2

启动测试

root@node2:~# cat docker-compose.yaml
services:nginx:image: nginx:web2ports:- "80:80"nginx2:image: nginx:web2ports:- "8080:80"
root@node2:~# docker-compose up -d
[+] Running 2/2✔ Container root-nginx-1   Started✔ Container root-nginx2-1  Started root@node2:~# curl localhost
web2
root@node2:~# curl localhost:8080
web2

改变镜像测试

root@node2:~# cat docker-compose.yaml
services:nginx:image: nginx:web1ports:- "80:80"nginx2:image: nginx:web2ports:- "8080:80"
root@node2:~# docker restart nginx          # 执行重启,不会更新服务
root@node2:~# curl localhost
web2root@node2:~# docker-compose up -d     
[+] Running 2/2✔ Container root-nginx-1   Started     # 更新变化的服务,并重启✔ Container root-nginx2-1  Running     # 没有变化的服务无变化root@node2:~# docker ps
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:~# cat web.conf
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:~# cat docker-compose.yaml
services:nginx:image: nginx:web1volumes:- ./web.conf:/etc/nginx/conf.d/web.confports:- "80:80"- "8880:8880"nginx2:image: nginx:web2ports:- "8080:80"
root@node2:~# docker-compose up -d  # 
[+] Running 2/2✔ Container root-nginx2-1  Running✔ Container root-nginx-1   Started
root@node2:~# docker exec -it root-nginx-1 curl localhost:8880
web1

重启所有镜像–force-recreate

root@node2:~# docker-compose up -d --force-recreate   # 
[+] Running 2/2✔ Container root-nginx2-1  Started✔ Container root-nginx-1   Started  

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com