Home > CMS Tutorial > WordPress > How to deploy wordpress through service in swarm cluster

How to deploy wordpress through service in swarm cluster

藏色散人
Release: 2021-04-22 10:43:08
forward
1862 people have browsed it

How to deploy wordpress through service in swarm cluster

Create an overlay-driven network

docker network create -d overlay wordpress
[vagrant@swarm-manager ~]$ docker network ls
NETWORK ID NAME DRIVER SCOPE
q3rp3i79eud7 wordpress overlay swarm
Copy after login

Create mysql container

docker service create --name mysql --env MYSQL_ROOT_PASSWORD=root --env MYSQL_DATABASE=wordpress --network wordpress --mount type=volume,source=mysql-data,destination=/var/lib/mysql mysql
Copy after login

Create wordpress

docker service create --name wordpress -p 80:80 --env WORDPRESS_DB_PASSWORD=root --env WORDPRESS_DB_HOST=mysql --network wordpress wordpress
Copy after login

View node distribution

# 服务列表
[vagrant@swarm-manager ~]$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
vxz0bfmul9th mysql replicated 1/1 mysql:5.7.22
cpe3wqrsoqxi wordpress replicated 1/1 wordpress:latest *:80->80/tcp

# wordpress服务的节点分布
[vagrant@swarm-manager ~]$ docker service ps wordpress
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
tnh4f0ldyidl wordpress.1 wordpress:latest swarm-manager Running Running 4 minutes ago

# mysql服务的节点分布
[vagrant@swarm-manager ~]$ docker service ps mysql
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
jns8bllzbz94 mysql.1 mysql:5.7.22 swarm-work1 Running Running 33 minutes ago
Copy after login

Although wordpress is only distributed on the node swarm-manager (192.168.205.10), we found that using the following link to access, the effect is the same, isn’t it amazing? . . . For specific reasons, see 7.6

http://192.168.205.10/
http://192.168.205.11/
http://192.168.205.12/
Copy after login
In swarm mode, there is no need to install etcd, swarm will automatically help us maintain the distributed overlay network

The above is the detailed content of How to deploy wordpress through service in swarm cluster. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template