Docker Community Forums

Share and learn in the Docker community.

Wordpress complete site

Hello,
I’m new to docker, this is my first project.
My goal is to have a complete wordpress in one directory. Here is what i want:

  • Wordpress
  • Mysql
  • phpMyAdmin
  • wp-cli (TODO)
  • VirtualHost (TODO)

I want to make a docker-compose up and have all the datas of my website in the same directory (DB + files).
It’s working fine with my files, everything is in ./wp-content, but it’s not the case with my db_data, it’s always use /var/lib/mysql (it was like that when i have launch docker-compose the first time).
Do you understand the problem ?
Thank you !

Here is my yml file:

version: '2'
services:
  wordpress:
    depends_on:
      - db
    image: wordpress
    restart: always
    volumes:
      - ./wp-content:/var/www/html/wp-content
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: p4ssw0rd!
    ports:
      - 85:80
      - 444:444
    networks:
      - back
  db:
    image: mysql:5.7
    restart: always
    volumes:
       - ./db_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: p4ssw0rd!
    networks:
      - back
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - 8080:80
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: p4ssw0rd!
    networks:
      - back
networks:
  back: