Skip to content

Instantly share code, notes, and snippets.

@danielyewright
Last active September 20, 2024 16:50
Show Gist options
  • Save danielyewright/460477844f9fe7b333f406c6d1f277b1 to your computer and use it in GitHub Desktop.
Save danielyewright/460477844f9fe7b333f406c6d1f277b1 to your computer and use it in GitHub Desktop.
Docker WordPress Dev
version: "3"
services:
# Container 1
# https://hub.docker.com/_/mysql
db:
image: mysql:5.7
restart: always
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wp
# Container 2
# https://hub.docker.com/_/wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
restart: always
volumes: ["./:/var/www/html/wp-content"]
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_CONFIG_EXTRA: |
define('FS_METHOD', 'direct');
ports:
- 80:80
networks:
- wp
# Container 3
# https://hub.docker.com/r/phpmyadmin/phpmyadmin
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin:latest
restart: always
ports:
- 8080:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- wp
networks:
wp:
volumes:
db_data:
@danielyewright
Copy link
Author

Latest for MariaDB

services:
  db:
    # We use a mariadb image which supports both amd64 & arm64 architecture
    image: mariadb:10.6.4-focal
    # If you really want to use MySQL, uncomment the following line
    #image: mysql:8.0.27
    command: '--default-authentication-plugin=mysql_native_password'
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=somewordpress
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
    expose:
      - 3306
      - 33060
  wordpress:
    image: wordpress:latest
    volumes:
      - wp_data:/var/www/html
    ports:
      - 80:80
    restart: always
    environment:
      - WORDPRESS_DB_HOST=db
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=wordpress
      - WORDPRESS_DB_NAME=wordpress
volumes:
  db_data:
  wp_data:

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