Skip to content

Instantly share code, notes, and snippets.

@AliKhadivi
Last active September 11, 2022 15:29
Show Gist options
  • Save AliKhadivi/37c56efdfe56ebe717d7990ca789383b to your computer and use it in GitHub Desktop.
Save AliKhadivi/37c56efdfe56ebe717d7990ca789383b to your computer and use it in GitHub Desktop.

Wordpress & Mysql & PhpMyAdmin with Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called docker-compose.yaml and run the command

For run

$ docker-compose up -d

For stop and remove containers & remove network

$ docker-compose down

For stop and remove containers & remove network & remove volume

$ docker-compose down --volumes

warning: If you run the above command, will erase all WordPress data and you will lose your data!

version: '3'
services:
db:
image: 'mysql:latest'
volumes:
- 'db_data:/var/lib/mysql'
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- site-network
wordpress:
depends_on:
- db
image: 'wordpress:latest'
volumes:
- 'site_data:/var/www/html/wp-content'
ports:
- '8000:80'
restart: always
environment:
WORDPRESS_DB_HOST: 'db:3306'
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
networks:
- site-network
phpmyadmin:
depends_on:
- db
image: phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- site-network
networks:
site-network: {}
volumes:
db_data: {}
site_data: {}
@AliKhadivi
Copy link
Author

Wordpress port: 8000
PMA port: 8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment