Skip to content

Instantly share code, notes, and snippets.

@Cursedpotential
Last active November 4, 2021 23:09
Show Gist options
  • Save Cursedpotential/7ea2fe83b2bc55594f6e8ce4b4926453 to your computer and use it in GitHub Desktop.
Save Cursedpotential/7ea2fe83b2bc55594f6e8ce4b4926453 to your computer and use it in GitHub Desktop.
Wordpress Docker Compose with MySQL, Create Web network before deployment. Ready to add RProxy Container and remove WP from web network.

Simple Wordpress Install on Docker

This file will setup Wordpress & MySQL with a single command.

Steps:

Create a new folder to house your docker-compose file and mount our WP volumes in. I will be using $HOME/wordpress_docker/:

$ cd && mkdir wordpress_docker 
$ cd wordpress_docker	

Add the code below to a file called "docker-compose.yaml" and run the command:

version: '3'

services:
  wp:
    image: wordpress:latest # https://hub.docker.com/_/wordpress/
    ports:
      - 8080:80 # change ip if required
    restart: always
    volumes:
      - ./config/php.conf.ini:/usr/local/etc/php/conf.d/conf.ini
      - ./wp-app:/var/www/html # Full wordpress project
      #- ./plugin-name/trunk/:/var/www/html/wp-content/plugins/plugin-name # Plugin development
      #- ./theme-name/trunk/:/var/www/html/wp-content/themes/theme-name # Theme development
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: P@ssw0rd123
    depends_on:
      - db
 
  db:
    image: mysql:latest # https://hub.docker.com/_/mysql/ - or mariadb https://hub.docker.co>
    volumes:
      - ./wp-data:/docker-entrypoint-initdb.d
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: P@ssw0rd123
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: P@ssw0rd123

volumes:
  db_data:

 docker-compose up -d

After that you can go to http://localhost:8080 to finish setting up wordpress.

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