Volume mounts when setting up WordPress with docker [closed]

Quickstart: Compose and WordPress proposes the following docker-compose.yml

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - dbdata:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    dbdata:

For persisting database data, a volume is created:

  • The docker volume db_data persists any updates made by WordPress to the database.

but nothing is mentioned about the wordpress container…

Questions:

  1. should I follow the same approach and create volumes for the wordpress container, in order to persist the data that are going to be added (by posts, uploads, themes)?
  2. If yes, which paths / directories should I point to?

Update 👇:

Same question on stackoverflow has drawn more attention: Volume mount when setting up WordPress with docker

0

Leave a Comment