Create multiple wordpress websites with Docker-Compose

This docker compose file creates 2 wordpress sites on one VPS server (vasulka.cz and tcoil.info). Uses reverse proxy for correct redirection. WordPress sites and associated databases run in Docker container. Nginx reverse proxy is not containerized yet since I have experienced some issues with port redirection when it was in the container.

Docker compose file:

$ cat docker-compose.yaml
version: '3.0'

# this docker file builds 2 wordpress websites:
# vasulka.cz and tcoil.info
# each site has its own database

# source paths to files or directories
# are relative to location of docker.compose.yaml file

services:

 wordpress_vasulka_cz:
    image: wordpress
    links:
     - mariadb_vasulka_cz:mysql
    environment:
     - WORDPRESS_DB_PASSWORD=password
    ports:
     - "8080:80"
    volumes:
     - ./html_vasulka_cz:/var/www/html
    restart: always

 wordpress_tcoil_info:
    image: wordpress
    container_name: wordpress_tcoil_info
    links:
     - mariadb_tcoil_info:mysql
    environment:
     - WORDPRESS_DB_PASSWORD=password
    ports:
     - "8081:80"
    volumes:
     - ./html_tcoil_info:/var/www/html
    restart: always 

 mariadb_vasulka_cz:
    image: mariadb
    environment:
     - MYSQL_ROOT_PASSWORD=password
     - MYSQL_DATABASE_0=wordpress_vasulka_cz
    volumes:
     - ./database_vasulka_cz:/var/lib/mysql
    restart: always 

 mariadb_tcoil_info:
    image: mariadb
    environment:
     - MYSQL_ROOT_PASSWORD=password
     - MYSQL_DATABASE_1=wordpress_tcoil_info
    volumes:
     - ./database_tcoil_info:/var/lib/mysql
    restart: always 
coil@coil:~/Desktop/tcoil.info/docker-dir$

Config of reverse proxy (nginx) for both enabled websites:

coil@coil:/etc/nginx/sites-enabled$ ls
tcoil.info  vasulka.cz
coil@coil:/etc/nginx/sites-enabled$ 
coil@coil:/etc/nginx/sites-enabled$ cat vasulka.cz 
server {
    listen 80;
    server_name vasulka.cz www.vasulka.cz;

    location / {
        proxy_pass http://localhost:8080;
    }
}
$ 
coil@coil:/etc/nginx/sites-enabled$ cat tcoil.info 
server {
    listen 80;
    server_name tcoil.info www.tcoil.info;

    location / {
        proxy_pass http://localhost:8081;
    }
}
$

Prototype of configuration with dockerized nginx:

git clone https://github.com/tristcoil/create-multiple-wordpress-sites-with-docker-compose.git

Sources: