Building Wordpress application using Docker Swarm
|Platform||Number of Instance||Reading Time|
|Play with Docker||5||5 min|
- Create an account with DockerHub
- Open PWD Platform on your browser
- Click on “Template” sign near to Instance on the left side of the PWD window.
- Select 3 Managers and 2 worker nodes template from drop-down menu
- This will bring up 5-Node Docker Swarm Mode cluster for you.
Create a WordPress Docker Compose file for Docker Swarm
version: '3.6' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: wordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress deploy: placement: constraints: [node.role == worker] replicas: 1 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_PASSWORD: wordpress deploy: placement: constraints: [node.role == worker] replicas: 1 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure volumes: db_data:
Save the file with a name “stack.yml”.
Bring up WordPress Application Stack
$ docker stack deploy -c stack.yml myapp4 Creating network myapp4_default Creating service myapp4_db Creating service myapp4_wordpress
A Port 8000 will appear instantly. Wait for 20 seconds and then click it to open WordPress App.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.