Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Steps to build a docker swarm cluster

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the steps of building a docker swarm cluster. The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the steps of building a docker swarm cluster.

1. Select the manager node and create a cluster

Choose any machine as the manager node and run on the machine:

Docker swarm init-the IP address of the current advertise-addr machine

After the run is complete, the following situation indicates success, and the command in the copy red area is left unused:

Note: the token in the red area is the unique ID of the cluster. All subsequent node machines need to join the current cluster through the commands in the red area.

two。 Add Cluster Node

Copying the contents in the red area in the previous step is executed on other node machines, and the following message will be prompted if the operation is successful:

This node joined a swarm as a worker.

After all the nodes have joined, you can run the following command on the primary node to check the status of the nodes:

Docker node ls

4. Deploy Portainer

Can manage docker stack, docker network, docker services, docker images, docker containers, etc., anything executed by command can be operated and managed on the interface through Portainer.

a. Prepare the docker-stack-manager.yml profile

Version: "3.2" services:#docker Cluster Visualization tool portainer: image: portainer/portainer hostname: portainer ports:-"9000 image 9000" volumes:-"/ var/run/docker.sock:/var/run/docker.sock"-"/ data/portainer:/data" deploy: replicas: 1 placement: constraints: [node.role = = manager] resources : limits:# cpus:'1' memory: 1GB reservations:# cpus: '0.2' memory: 512MB

b. Create a file directory

c. Execute docker-stack-manager.yml file

Docker stack deploy-c docker-stack-manager.yml manager-- resolve-image=never

Note: the command must be executed in the same directory as docker-stack-manager.yml. After the execution is complete, please wait a moment. The installation will take some time. You can check the installation progress by executing the following command on manager:

Docker service ls

d. Access interface address http:// cluster IP:9000

e. Start configuring account password

f. Information about configuring manager node hosts

Note: Name-- write whatever; Endpoint URL-- IP:2375; port 2375 of the manager node is the default port. If the addition fails, you can try the following methods:

Execute a command

Vim / lib/systemd/system/docker.service

Join in ExecStart:

-H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock

Restart dokcer

Systemctl daemon-reloadsystemctl restart docker

5. Configure a private server image warehouse on each node

Privately serve the address of the image warehouse on each node

Vim / etc/docker/daemon.json

If daemon.json already exists, please add it to the original. If there are more than one, separate them with commas. The configuration is as follows:

{"insecure-registries": ["Private server IP address 1: private server port", "private server IP address 2: private server port"], "registry-mirrors": ["https://registry.docker-cn.com"]}"

Restart the docker service

Systemctl daemon-reloadsystemctl restart docker

Verify that it was successful:

Docker info

The following shows that it is successful

6.

Click the menu "registries" on the left, click "Add registry", select "custom registry", and enter the private server image repository information. If there are more than one, add it multiple times.

At this point, the docker swarm cluster building has been completed.

Thank you for your reading. The above is the content of "steps for building docker swarm clusters". After the study of this article, I believe you have a deeper understanding of the steps of building docker swarm clusters, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report