zoukankan      html  css  js  c++  java
  • Docker Swarm 配置文件存储

    Docker Swarm 配置文件存储

    • config:宿主级容器服务配置文件单独保存到docker中存储调用。

    环境:

    • 系统:Centos 7.4 x64
    • 应用版本:Docker 18.09.0
    • 管理节点:192.168.1.79
    • 工作节点:192.168.1.78
    • 工作节点:192.168.1.77

    1、管理节点:宿主级当前目录创建Nginx配置文件

    vim site.conf

    server {
    listen 80;
    server_name localhost;
    location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    }
    }

    2、管理节点:将site.conf保存到docker配置存储中

    #  docker config create docker 配置文件名 本地配置文件
    docker config create site.conf site.conf

    3、管理节点:创建一个Nginx并应用这个配置

    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 
    命令解析

    4、工作节点:切换到容器查看配置文件

    # 切换到容器内
    # cat /etc/nginx/conf.d/site.conf
    server {
    listen 80;
    server_name localhost;
    location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    }
    }

    5、浏览器访问

  • 相关阅读:
    利用userData实现客户端保存表单数据
    随机提取10条记录
    分页的文本显示
    用VB.NET写的一个简易的RSS阅读器
    怎样提高你的Google Adsense收入?
    全球500家最大公司及网址
    HTC教程
    老百姓是这样买房的
    使用JavaScript+XML实现分页
    恋爱的奇妙感觉,当爱在靠近...
  • 原文地址:https://www.cnblogs.com/xiangsikai/p/9939421.html
Copyright © 2011-2022 走看看