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 #生成manager节点 leave Leave the swarm #离开集群节点 unlock Unlock swarm unlock-key Manage the unlock key update Update the swarm
初始化节点
[root@VM_0_8_centos ~]# docker swarm init --help
Usage: docker swarm init [OPTIONS]
Initialize a swarm
Options: --advertise-addr string Advertised address (format: <ip|interface>[:port]) # IP地址 --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>) --data-path-port uint32 Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the default port (4789) is used. --default-addr-pool ipNetSlice default address pool in CIDR format (default []) --default-addr-pool-mask-length uint32 default address pool subnet mask length (default 24) --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)
Commands: create Create a new service #创建一个服务(容器) inspect Display detailed information on one or more services #查看服务详细信息 logs Fetch the logs of a service or task #查看服务日志 ls List services ps List the tasks of one or more services #查看运行服务 rm Remove one or more services #删除服务 rollback Revert changes to a service's configuration #回滚操作 scale Scale one or multiple replicated services #创建多个副本 update Update a service #更新多个副本 --replicas uint Run 'docker service COMMAND --help' for more information on a command.
docker service和docker run类似
启动tomcat环境
docker service create -p 8080:80 --name mynginx nginx