moxdev
8/10/2017 - 2:25 PM

Docker compose file to spin up a wordpress site

Docker compose file to spin up a wordpress site

version: "3"

services:
  db:
    image: mariadb
    # uncomment the following two lines for data persistence
    volumes:
      - ./db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    # uncomment the following lines, to be able to access the database on your machine
    ports:
      - "3306:3306"
    networks:
      - backend

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - ./wordpress:/var/www/html
    ports:
      - "8000:80"
    restart: always
    volumes:
      - ./wp-content:/var/www/html/wp-content
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    networks:
      - backend

  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - 8080:80
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: root
    networks:
      - backend

networks:
  backend:
volumes:
  db_data: