Docker Community Forums

Share and learn in the Docker community.

How to mount 2 volumes from a single docker-compose file?


(Dockerklewis) #1

Hi!
I’m super new to this docker community. You guys have a pretty-cool-looking site. I read through some volume questions here on the forums but have not found any that relate to my issue. I am very comfortable in building a single docker-compose.yml file for a single instance of WordPress, like this…

version: '3.1'

services:

  Rise:
    image: mysql:5.7
    volumes: 
      - ./mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: wp

  wordpress:
    image: wordpress:4.8.2-apache
    restart: always
    ports:
      - 8081:80
    volumes:
      - ./wp/html:/var/www/html/
    links:
      - Rise:mysql
    environment:
      WORDPRESS_DB_PASSWORD: wp
      WORDPRESS_TABLE_PREFIX: risedockerlocal01_

My goal now, is to learn how to run two volume locations, one for each WordPress instance, at the same time, all within a single docker-compose file.

I basically want both http://localhost:8081 and http://localhost:8082 up and running at the same time with their own mounted volumes.

Also, both instances use the same MySQL database but have different TABLE_PREFIXES.

What must I do to enhance this docker-compose.yml file structure to meat these requirements?

My end goal is to use a single docker-compose.yml file to run all my local development wordpress sites (instead of creating a docker-compose file for each instance).

Thanks!