赞
踩
//创建存放网站的和配置文件的目录 [root@docker ~]# mkdir -p /var/www/html [root@docker ~]# mkdir /config #配置文件可yum安装Nginx,再copy到/config目录 [root@docker ~]# ls /var/www/html/ index.html [root@docker ~]# ls /config/ conf.d mime.types.default default.d nginx.conf fastcgi.conf nginx.conf.default fastcgi.conf.default scgi_params fastcgi_params scgi_params.default fastcgi_params.default uwsgi_params koi-utf uwsgi_params.default koi-win win-utf mime.types //创建数据卷容器 [root@docker nginx]# docker run --name html -v /var/www/html/:/usr/share/nginx/html busybox #-v:将宿主机目录映射到容器目录 Unable to find image 'busybox:latest' locally latest: Pulling from library/busybox 3cb635b06aa2: Pull complete Digest: sha256:70eb6b39a8db2834d27b221899aa6c30a4d9648c804cf0586d8d6ea202327fe7 Status: Downloaded newer image for busybox:latest [root@docker nginx]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 109a44ecb413 busybox "sh" 5 minutes ago Exited (0) 5 minutes ago html //测试 [root@docker nginx]# docker run -it --rm --volumes-from html busybox / # ls /usr/share/nginx/html/ index.html [root@docker ~]# docker run --volumes-from html -v /config/:/etc/nginx --name nginx_conf busybox [root@docker ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3e99ef74777e busybox "sh" 14 seconds ago Exited (0) 13 seconds ago nginx_conf 109a44ecb413 busybox "sh" 8 minutes ago Exited (0) 8 minutes ago html //测试 [root@docker ~]# docker run -it --rm --volumes-from nginx_conf busybox / # ls /usr/share/nginx/html/ html-editor-master index.html / # ls /etc/nginx/ conf.d mime.types.default default.d nginx.conf fastcgi.conf nginx.conf.default fastcgi.conf.default scgi_params fastcgi_params scgi_params.default fastcgi_params.default uwsgi_params koi-utf uwsgi_params.default koi-win win-utf mime.types / # exit //基于Nginx镜像创建数据卷容器 [root@docker ~]# docker run -d --name web --volumes-from nginx_conf -P nginx Unable to find image 'nginx:latest' locally latest: Pulling from library/nginx e5ae68f74026: Pull complete 21e0df283cd6: Pull complete ed835de16acd: Pull complete 881ff011f1c9: Pull complete 77700c52c969: Pull complete 44be98c0fab6: Pull complete Digest: sha256:9522864dd661dcadfd9958f9e0de192a1fdda2c162a35668ab6ac42b465f0603 Status: Downloaded newer image for nginx:latest ca2325c6127c17db7d0459ac09355db20ddab0281e80a1c8358bd316a4617221 [root@docker ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ca2325c6127c nginx "/docker-entrypoint.…" 25 seconds ago Up 23 seconds 0.0.0.0:49153->80/tcp, :::49153->80/tcp web [root@docker ~]# docker exec -it web /bin/bash root@ca2325c6127c:/# ls /etc/nginx/ conf.d mime.types.default default.d nginx.conf fastcgi.conf nginx.conf.default fastcgi.conf.default scgi_params fastcgi_params scgi_params.default fastcgi_params.default uwsgi_params koi-utf uwsgi_params.default koi-win win-utf mime.types root@ca2325c6127c:/# ls /usr/share/nginx/html/ index.html
访问
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。