美文网首页
docker swarm

docker swarm

作者: 李小二的倔强 | 来源:发表于2021-11-08 17:53 被阅读0次
    [root@localhost odc]# docker swarm -h
    Flag shorthand -h has been deprecated, please use --help
    
    Usage:  docker swarm COMMAND
    
    Manage Swarm
    
    Commands:
      ca          Display and rotate the root CA
      init        Initialize a swarm
      join        Join a swarm as a node and/or manager
      join-token  Manage join tokens
      leave       Leave the swarm
      unlock      Unlock swarm
      unlock-key  Manage the unlock key
      update      Update the swarm
    
    Run 'docker swarm COMMAND --help' for more information on a command.
    
    [root@localhost odc]# docker swarm init -h
    Flag shorthand -h has been deprecated, please use --help
    
    Usage:  docker swarm init [OPTIONS]
    
    Initialize a swarm
    
    Options:
          --advertise-addr string           Advertised address (format: <ip|interface>[:port])
          --autolock                        Enable manager autolocking (requiring an unlock key to start a stopped manager)
          --availability string             Availability of the node ("active"|"pause"|"drain") (default "active")
          --cert-expiry duration            Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
          --data-path-addr string           Address or interface to use for data path traffic (format: <ip|interface>)
          --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
          --external-ca external-ca         Specifications of one or more certificate signing endpoints
          --force-new-cluster               Force create a new cluster from current state
          --listen-addr node-addr           Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
          --max-snapshots uint              Number of additional Raft snapshots to retain
          --snapshot-interval uint          Number of log entries between Raft snapshots (default 10000)
          --task-history-limit int          Task history retention limit (default 5)
    
    [root@localhost odc]# docker node -h
    Flag shorthand -h has been deprecated, please use --help
    
    Usage:  docker node COMMAND
    
    Manage Swarm nodes
    
    Commands:
      demote      Demote one or more nodes from manager in the swarm
      inspect     Display detailed information on one or more nodes
      ls          List nodes in the swarm
      promote     Promote one or more nodes to manager in the swarm
      ps          List tasks running on one or more nodes, defaults to current node
      rm          Remove one or more nodes from the swarm
      update      Update a node
    
    Run 'docker node COMMAND --help' for more information on a command.
    

    docker swarm 创建容器

    docker service create --name [容器名称] 镜像名称
    docker service create --name my-tomcat tomcat
    

    docker swarm 查看容器

    docker service ps my-tomcat
    

    查看启动日志

    docker service logs  my-tomcat
    

    添加副本

    docker service scale my-tomcat=3
    

    删除容器

    docker service rm [容器名]
    docker service rm my-tomcat
    

    docker stack (类似于docker-compose,通过yml 文件启动)

    [root@localhost odc]# docker stack
    
    Usage:  docker stack [OPTIONS] COMMAND
    
    Manage Docker stacks
    
    Options:
          --orchestrator string   Orchestrator to use (swarm|kubernetes|all)
    
    Commands:
      deploy      Deploy a new stack or update an existing stack
      ls          List stacks
      ps          List the tasks in the stack
      rm          Remove one or more stacks
      services    List the services in the stack
    
    Run 'docker stack COMMAND --help' for more information on a command.
    
    docker stack deploy -c service.yml [my-servce]
    

    创建网络

    docker network create  -d overlay my-overlay-net 
    

    conclusion : 集群中的任意机器都能访问成功
    internal 技术 :负载均衡

    相关文章

      网友评论

          本文标题:docker swarm

          本文链接:https://www.haomeiwen.com/subject/dkbrzltx.html