Centos 7 安装Docker

# 初使化安装环境
yum -y install yum-utils gcc g++ kernel-devel

# 添加yum 仓库并更新
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast


# 安装并以服务方式启动docker
sudo yum -y install docker-ce
sudo systemctl enable docker
sudo systemctl start docker
2018/5/16 21:9 下午 posted in  Docker CentOs

Docker Swarm常用命令集合

# 初使化Swarm 192.168.1.1为对外IP
docker swarm init --listen-addr 192.168.1.1:2377 --advertise-addr 192.168.1.1

# 查看Worker Token
docker swarm join-token worker

# Worker加入集群 替换对应token值
docker swarm join --token \
SWMTKN-1-5eukghd8e9wby5aw8t8y4rdz425euoo8m9qgmgitpxg63ax2ol-94dvz9vrx5oai22jc3vl2eh56 \
192.168.1.1:2377

# 查看Manager Token
docker swarm join-token manager

# Manager加入集群 替换对应token值
docker swarm join --token \
SWMTKN-1-5eukghd8e9wby5aw8t8y4rdz425euoo8m9qgmgitpxg63ax2ol-94dvz9vrx5oai22jc3vl2ehed2 \
192.168.1.1:2377

# 查看集群中的节点 在Manager机器人执行
docker node ls

# 创建虚拟网络
docker network create --driver overlay --subnet 10.0.10.0/24 \
  --opt encrypted test_network
  
# Centos 7 防火墙开放端口
firewall-cmd --add-port=2376/tcp --permanent
firewall-cmd --add-port=2377/tcp --permanent
firewall-cmd --add-port=7946/tcp --permanent
firewall-cmd --add-port=7946/udp --permanent
firewall-cmd --add-port=4789/udp --permanent
sudo firewall-cmd --reload
2018/5/16 21:1 下午 posted in  Docker CentOs