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