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

Installation of docker and usage of docker services command

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about docker installation and the use of docker services commands. I think it's very practical, so I share it with you. The following information is about docker installation and docker services command usage.

VirtualBox opens 3 virtual machines

host manifest

swarm01 192.168.0.127

swarm02 192.168.0.128

swarm03 192.168.0.129

install Docker

$ curl -fsSL get.docker.com -o get-docker.sh

$ sudo sh get-docker.sh --mirror Aliyun

# $ sudo sh get-docker.sh --mirror AzureChinaCloud

sudo systemctl start docker

sudo systemctl enable docker

Local 3 NIC, broadcast on enp0s3 192.168.0.127 bridge NIC enp0s8

docker swarm init --advertise-addr 192.168.0.127

Password added to work

docker swarm join --token SWMTKN-1-0wlbnf7ezi6d39j7m0sv9912ikzf13f10jgk384ttiuj6ovy88-4sjlkdp9ul3fe353b0iq0q56c 192.168.0.127:2377

docker node ls

3 machines joining the cluster can be found.

A hello service.

docker search alpine

docker pull registry.docker-cn.com/library/alpine

docker service create --replicas 1 --name hello busybox

Registry is not there?

Nginx should have it.

docker service create --name my_web nginx

docker service ls

Creating a task

docker service create --name helloworld alpine ping www.baidu.com

docker service ls

nginx service plus a port

docker service update --publish-add 80 my_web

docker service scale my_web=3

If you do something wrong, you can rollback.

docker service update --replicas=5 my_web

docker service update --rollback my_web

192.168.0.127-129 All three servers can access the NAT port 3000 of the external network of nginx

Where did this 30000 port come from? Let me update it.

docker service update \

--publish-add published=80,target=80 \

my_web

Node 80 port can access birds

docker network ls

There are two types of network, bridge is the external access, overlay is the internal communication network of the container

docker network create -d overlay --attachable swarm_test

Add swarm communication network card

Develop networks when creating services

docker service create \

--replicas 3 \

--network swarm_test \

--name my_web2 \

nginx

Compare the difference between the two services

docker service inspect my_web

docker service inspect my_web2

The network is different.

Other docker services commands

docker service create

Create a new service

docker service inspect

Display detailed information on one or more services

docker service logs

Fetch the logs of a service or task

docker service ls

List services

docker service ps

List the tasks of one or more services

docker service rm

Remove one or more services

docker service rollback

Revert changes to a service's configuration

docker service scale

Scale one or multiple replicated services

docker service update

Update a service

About docker installation and docker services command usage shared here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you like this post, share it with more people.

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

Servers

Wechat

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

12
Report