zoukankan      html  css  js  c++  java
  • create a swarm

    create a swarm

    • 创建一个新的集群
        docker swarm init --advertise-addr <MANAGER-IP>
    
    • Run docker info to view the current state of the swarm:
        $ docker info
        Containers: 2
        Running: 0
        Paused: 0
        Stopped: 2
        ..snip...
        Swarm: active
        NodeID: dxn1zf6l61qsb1josjja83ngz
        Is Manager: true
        Managers: 1
        Nodes: 1
        ...snip...
    
    [root@centos5 ~]# docker node ls
    ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
    ip2fs5kkfpllyexal8pxuxnlq     centos4             Ready               Active              
    t7998hft3zw479evc7lr8irx2 *   centos5             Ready               Active              Leade
    
    • run the following command on a manager node to retrieve the join command for a worker
        docker swarm join-token worker
        [root@centos5 ~]# docker swarm join-token worker
        To add a worker to this swarm, run the following command:
    
        docker swarm join --token SWMTKN-1-1705vcetk9pgd3nb9zph2izwtcudq1ajeh7b13wqcst46epk18-bltg74jq3ql7zrswirt6xhwm3 10.173.38.40:2377
    
    
    • use command to create a severvice:
        docker service create --replicas 1 --name helloworld alpine ping docker.com
    
    • Run docker service inspect --pretty to display the details about a service in an easily readable format.
    [root@centos5 ~]# docker service inspect --pretty helloworld
    
    ID:		vk639rdtes0pw8anp7dxnznzu
    Name:		helloworld
    Service Mode:	Replicated
    Replicas:	1
    Placement:
    UpdateConfig:
    Parallelism:	1
    On failure:	pause
    Monitoring Period: 5s
    Max failure ratio: 0
    Update order:      stop-first
    RollbackConfig:
    Parallelism:	1
    On failure:	pause
    Monitoring Period: 5s
    Max failure ratio: 0
    Rollback order:    stop-first
    ContainerSpec:
    Image:		alpine:latest@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe
    Args:		ping docker.com 
    Resources:
    Endpoint Mode:	vip
    
    • Run docker service ps to see which nodes are running the service:
    
    [root@centos5 ~]# docker service ps helloworld
    ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
    zgeljyk5fqf6        helloworld.1        alpine:latest       centos5             Running             Running 8 minutes ago                       
    

    *Run the following command to change the desired state of the service running in the swarm:

    $ docker service scale <SERVICE-ID>=<NUMBER-OF-TASKS>
    
    • Now you can update the container image for redis. The swarm manager applies the update to nodes according to the UpdateConfig policy:
    docker service update --image redis:3.0.7 redis
    
  • 相关阅读:
    合并指定表格指定列的相同文本的相邻单元格
    [转载]>/dev/null 2>&1 含义
    有关cron
    jQuery版本对checkbox影响
    c# 如何获取项目的根目录
    Javascript 字符串组装用函数 format
    sql server 删除数据库
    说说接口封装
    有开放的接口!!!!
    支付宝支付功能的集成
  • 原文地址:https://www.cnblogs.com/Ethan2lee/p/7512979.html
Copyright © 2011-2022 走看看