Abstract: This paper mainly describes the simple construction of Docker Swarm cluster and the basic management use based on Poratiner. The following article will update the fully automated CI based on Harbor + Jenkins

DockerEnvironment to prepare

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo yum list Docker - ce - showduplicates | sort - r # version installation specified yum install docker - ce - yum source 20.10.7 # add ali cloud, Cat <<EOF > /etc/dock/daemon. json {"registry-mirrors": [ "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "Https://docker.mirrors.ustc.edu.cn"]} EOF # start docker systemctl enable docker && systemctl start dockerCopy the code

Docker SwarmCluster Initialization

  • The primary node is initialized. At the back of theIPWrite a host IP
Docker swarm init --advertise-addr 192.168.137.130 docker swarm join-token worker docker swarm init --advertise-addr 192.168.137.130 Docker swarm join-token manager: View the command added to the manager docker swarm join-token -- Rotate worker: reset the woker token. Docker swarm join-token-q worker: Prints only tokens.Copy the code

  • The child node joins the master node and executes the following command (the master node outputs this)

docker swarm join --token SWMTKN-1-3y6qxyq2o4e8utshuw5mw6f84irior5u0j83zm6fbyaos4sar8-2imf9e3aep4g4ah6wf5mxp9sq 192.168.137.130:2377

  • Viewing Cluster Status
Docker node ls # docker node --helpCopy the code

PortainerManagement Platform Deployment

Download the deployment file https://downloads.portainer.io/portainer-agent-stack.yml execute commands docker stack deploy – c portainer – agent – stack. Yml portainer

View the service Docker service ls

The rest is done on Portainer, next CI/CD