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

  • 相关阅读:
    Matlab产生随机序列,并采样
    LaTex的常用编辑
    傅里叶级数(FS)以及FT、DTFT、DFS和DFT
    uint32_t
    string
    const char * char const * char * const
    CString
    UNICODE与ANSI的区别
    MFC中输出string;
    assert
  • 原文地址:https://www.cnblogs.com/xiangsikai/p/9939421.html
Copyright © 2011-2022 走看看