In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to deploy Docker Swarm, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Software Information Software version OSUbuntu 16.04.3 LTSDocker18.03.0-ce Host Information ubuntu16.04-1172.31.68.241swarm managerubuntu16.04-2172.31.68.242swarm nodeubuntu16.04-3172.31.68.243swarm nodeswarm initialization managerdocker swarm init-- advertise-addr 172.31.68.241
Initialize workerdocker swarm join-- token SWMTKN-1-1mn8x6itne5ldwad5bmtgtdkemoim3o53dc7u2b5y5zj1lwj4l-etyttp60hpns5i4jifym7y3hd 172.31.68.241pur2377
Ps: be careful to execute on both worker
View node status docker node ls
Disable the worker function of manager docker node update-- availability drain ubuntu16.04-1
Ps: so you don't assign execution tasks on manager.
Add labeldocker node update-- label-add app ubuntu16.04-2docker node update-- label-add app ubuntu16.04-3 to worker to view the details of a node docker node inspect ubuntu16.04-3
Ps: to view a specific piece of information, you can use the following command mode
Docker node inspect ubuntu16.04-3-- format "{{.Status.Addr}}" create service create service, one copy docker service create-- replicas 1-p 4000 service 80-- name hello 172.31.68.241/library/friendlyhello
View servicedocker service lsdocker service ps hello
Ps: through service ps, you can see that the real task runs on ubuntu16.04-2, and the name of the container is hello.1.
View other node tasks docker container ls
Ps: you can see that on ubuntu16.04-2, the real name of the container is: service name + task id+ a string of random codes. There is no relevant task running on ubuntu16.04-3 because replicas is 1
View service details docker service inspect hello [{"ID": "woxqqkoqr6viu8flojtuuht97", "Version": {"Index": 25}, "CreatedAt": "2018-08-17T07:20:13.503484813Z", "UpdatedAt": "2018-08-17T07:20:13.515429684Z", "Spec": {"Name": "hello" "Labels": {}, "TaskTemplate": {"ContainerSpec": {"Image": "172.31.68.241/library/friendlyhello:latest@sha256:05def471119a0937508cdcb2445cb55375d15257b0a117e954bcd3527c36eac2", "StopGracePeriod": 10000000000, "DNSConfig": {} "Isolation": "default"}, "Resources": {"Limits": {}, "Reservations": {}}, "RestartPolicy": {"Condition": "any" "Delay": 5000000000, "MaxAttempts": 0}, "Placement": {"Platforms": [{"Architecture": "amd64" "OS": "linux"}]}, "ForceUpdate": 0, "Runtime": "container"} "Mode": {"Replicated": {"Replicas": 1}}, "UpdateConfig": {"Parallelism": 1, "FailureAction": "pause", "Monitor": 5000000000, "MaxFailureRatio": 0 "Order": "stop-first"}, "RollbackConfig": {"Parallelism": 1, "FailureAction": "pause", "Monitor": 5000000000, "MaxFailureRatio": 0, "Order": "stop-first"} "EndpointSpec": {"Mode": "vip", "Ports": [{"Protocol": "tcp", "TargetPort": 80, "PublishedPort": 4000 "PublishMode": "ingress"}, "Endpoint": {"Spec": {"Mode": "vip" "Ports": [{"Protocol": "tcp", "TargetPort": 80, "PublishedPort": 4000, "PublishMode": "ingress"}]} "Ports": [{"Protocol": "tcp", "TargetPort": 80, "PublishedPort": 4000, "PublishMode": "ingress"}] "VirtualIPs": [{"NetworkID": "zhamhv5cl7zhr7c7g6n1so6kv" "Addr": "10.255.0.5 + 16"}]}] visit servicecurl http://172.31.68.241:4000-Icurl http://172.31.68.242:4000-Icurl http://172.31.68.243:4000-I
Ps: the service can be accessed normally if you access any node in the swarm mode cluster.
Extended servicedocker service scale hello=2
View the result docker service ps hello of the extended thickness
Swarm config creates configdocker config create hello-config. / hello-config
View configdocker config ls
View details docker config inspect hello-config
Use configdocker service create-- replicas 1-- name config-test-- config source=hello-config,target=/mnt/hello-config 172.31.68.241/library/friendlyhello in service
View the running workerdocker service ps config-test of task
Enter the container to view the configuration docker container lsdocker container exec-it b06c415e7cac / bin/bash
Ps: if the source/target of config is not specified when starting service, the default mount directory of config in the container is / hello-config
View local directory information for config
Config is usually under the / var/lib/docker/containers/container_id/mounts/secrets directory of the host where the container is located, and is a random string file.
Swarm secret
The difference between config and secret is that one is local and the other is stored in tmpfs.
Create secret# view secretr file cat hello-config-secret# create secretdocker secret create hello-secret. / hello-config-secret# view secretdocker secret ls
Start the service# startup service docker service create with secret using secret in service-- replicas 1-- label app-- secret hello-secret-- name secret-test 172.31.68.241/library/friendlyhello# to see on which machine task is running docker service ps secret-test
View the secret information in the container docker container exec-it 47c8f6f74ae3 / bin/bash
Ps: when using secret, the secret configuration is usually under the / run/secrets/ directory, and the name is secret name.
Thank you for reading this article carefully. I hope the article "how to deploy Docker Swarm" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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: 271
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.