Setup
-
Install Docker
sudo apt install docker
-
Run Docker without sudo
sudo groupadd docker sudo usermod -aG $USER
-
Configure VMs
在virtualbox使多台ubuntu虚拟机位于同一局域网
VirtualBox实现内外网络互访问的配置
主机不能访问虚拟机中的web服务的解决方案
Deployment
-
Create Cluster
# on manager node docker swarm init
# on worker node # run "docker swarm join-token manager" to get $token and $IP # run below command on slave/worker node to join swarm docker swarm join --token $token $IP:2377
-
Create Network
docker network create -d overlay <network>
-
Create Service
docker service create --name <svc_name> [--network <network>] --replicas <num> -p <port:target_port> <image>
-
Rollout
docker service update --replicas <num>
docker service update --image <image:tag> <svc_name>
docker service update --update-delay <secs> --update-parallelism <num>
-
Inspection
docker service inspect --pretty <svc_name>s
-
Test
curl docker:<port>
网友评论