I want to bring up a local instance of an existing WordPress install using Docker. How can I:
- import the existing database...
- AND persist changes between my container restarts?
I can do each separately but cannot get both to work. If I use the db_data volume then I seem to start off with a clean database. If I don't - it imports my database from existing.sql but then I cannot persist my changes between container restarts.
My docker-compose.yml:
version: '3.3'
services:
  db:
    image: mysql:5.7
    volumes:
      - ./db/existing.sql:/docker-entrypoint-initdb.d/existing.sql
      - db_data:/var/lib/mysql # this works for task 2 but not task 1
    restart: always
    environment:
      # credentials here
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    volumes:
      - ./code/:/var/www/html/
    environment:
      # credentials here
volumes:
  db_data: {}  # this works for task 2 but not task 1
Do I need to use --volumes-from flag as described in the docs here?
 
    