Skip to content

Instantly share code, notes, and snippets.

@mariovalney
Created February 6, 2020 23:07
Show Gist options
  • Save mariovalney/7d23d8196a666cd2968d130d35368e72 to your computer and use it in GitHub Desktop.
Save mariovalney/7d23d8196a666cd2968d130d35368e72 to your computer and use it in GitHub Desktop.
Docker Compose to WordPress + Mailhog + Database + Network
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
- "3306:3306"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./docker/certs:/etc/nginx/certs
mailhog:
image: mailhog/mailhog
environment:
MH_STORAGE: maildir
MH_MAILDIR_PATH: /home/mailhog
VIRTUAL_HOST: mail.wordpress.localtest.me
VIRTUAL_PORT: 8025
networks:
- default
- nginx-proxy
volumes:
- mailhog:/home/mailhog
database:
image: mysql:5.7
restart: always
depends_on:
- nginx-proxy
expose:
- 3306
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_ROOT_PASSWORD: somewordpress
VIRTUAL_HOST: database.wordpress.localtest.me
VIRTUAL_PORT: 3306
networks:
- default
- nginx-proxy
volumes:
- database:/var/lib/mysql
wordpress:
image: wordpress:latest
restart: always
depends_on:
- database
- nginx-proxy
expose:
- 80
environment:
WORDPRESS_DB_HOST: database
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
VIRTUAL_HOST: wordpress.localtest.me
VIRTUAL_PORT: 80
networks:
- default
- nginx-proxy
volumes:
- ./www:/var/www/html
volumes:
database:
mailhog:
networks:
nginx-proxy:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment