• 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、浏览器访问

  • 相关阅读:
    excel unixtime与北京时间互转
    vim的漫漫长征路
    const常量
    第一章:绪论
    2.4奇偶校验
    2.3数据校验的基本原理
    2.2定点与浮点数据表示
    2.1机器数及其特点
    1.2计算机系统性能评价
    冯诺依曼结构原理及层次分析
  • 原文地址:https://www.cnblogs.com/xiangsikai/p/9939421.html
Copyright © 2020-2023  润新知