Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you! Deploying wordpress with Docker-Stack
Docker-swarm services will continue to be used this time, but this time it will use a relatively simple and convenient way to complete. Docker-compose is a locally developed tool that can be deployed locally. Docker-compose does bring a lot of convenience for wordpress and voting apps, but swarm is multi-node. Swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm swarm Source: github.com/limingios/d…
Docker – compose files
Edit the docker-compose file and download it from Github.
cd labs/
cd wordpress/
more docker-compose.yml
Copy the code
- The grammar of the composer
version: '3'
services:
web:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_PASSWORD: root
networks:
- my-network
depends_on:
- mysql
deploy:
mode: replicated
replicas: 3
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
update_config:
parallelism: 1
delay: 10s
mysql:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
volumes:
- mysql-data:/var/lib/mysql
networks:
- my-network
deploy:
mode: global
placement:
constraints:
- node.role == manager
volumes:
mysql-data:
networks:
my-network:
driver: overlay
Copy the code
Docker – stack deployment
- Docker stack deploy deployscompose template to docker cluster as a stack, equivalent to docker-compose up
- Docker Stack ls lists all current stacks *
- Docker stack PS shows a container in a stack, equivalent to the previous *
- docker-compose ps
- Docker Stack RM removes a stack and its containing services and containers
- With the docker stack command, you can easily deploy the Compose template to the docker cluster as a built-in orchestration Service.
Understand the basic command of docker Stack
docker stack
Copy the code
docker stack deploy wordpress --compose-file=docker-compose.yml
docker stack ps wordpress
docker stack services wordpress
Copy the code
PS: Docker-stack is used for multi-machine deployment by yML similar to docker-compose file.