Docker Swarm 配置文件存储html
环境:nginx
一、管理节点:宿主级当前目录建立Nginx配置文件docker
vim site.confvim
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } }
二、管理节点:将site.conf保存到docker配置存储中浏览器
# docker config create docker 配置文件名 本地配置文件 docker config create site.conf site.conf
三、管理节点:建立一个Nginx并应用这个配置ide
docker service create \ --name nginx \ --config source=site.conf,target=/etc/nginx/conf.d/site.conf \ --publish 8080:80 \ nginx:latest
# 建立服务 docker service create \ # 服务名 --name nginx \ #添加配置文件,source=docker配置文件,target=配置文件路径 --config source=site.conf,target=/etc/nginx/conf.d/site.conf \ # 暴露端口 --publish 8080:80 \ # 使用镜像 nginx:latest
四、工做节点:切换到容器查看配置文件spa
# 切换到容器内 # cat /etc/nginx/conf.d/site.conf server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } }
五、浏览器访问code