Skip to content

Instantly share code, notes, and snippets.

@phunguyen19
Last active May 5, 2022 16:30
Show Gist options
  • Select an option

  • Save phunguyen19/b53b738ee03ee06bd9326adc6340d782 to your computer and use it in GitHub Desktop.

Select an option

Save phunguyen19/b53b738ee03ee06bd9326adc6340d782 to your computer and use it in GitHub Desktop.
start wordpress docker compose
version: "3.9"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
- ./docker/my.cnf:/etc/my.cnf
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- wordpress_data:/var/www/html
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
wordpress_data: {}
@llbbl

llbbl commented May 2, 2022

Copy link
Copy Markdown

You'll want to bind mount your my.cnf so it can be modified without re-creating the container.

@phunguyen19

Copy link
Copy Markdown
Author

You'll want to bind mount your my.cnf so it can be modified without re-creating the container.

Thanks. This is new to me. Just added it. Hope this will help someone.

@llbbl

llbbl commented May 5, 2022

Copy link
Copy Markdown

Add a type parameter to change it to be of type bind on the file, keeping the folder as volume.

https://docs.docker.com/compose/compose-file/compose-file-v3/#volumes

Saw this come up on the public gist feed after I posted a new one. Just trying help ya out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment