-1

I'm using the following version of Docker on Mac High Sierra ...

localhost:maps davea$ docker-compose --version
docker-compose version 1.25.2, build 698e2846

I have created the below docker-compose.yml file. I would like my MySql volume to persist across bringing up and down my Docker containers ...

version: '3'

services:
  mysql:
    restart: always
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: 'maps_data'
      # So you don't have to use root, but you can if you like
      MYSQL_USER: 'chicommons'
      # You can use whatever password you like
      MYSQL_PASSWORD: 'password'
      # Password for root access
      MYSQL_ROOT_PASSWORD: 'password'
    ports:
      - "3406:3406"
    volumes:
      - my-db:/var/lib/mysql

  web:
    restart: always
    build: ./web
    ports:           # to access the container from outside
      - "8000:8000"
    env_file: .env
    environment:
      DEBUG: 'true'
    command: /usr/local/bin/gunicorn maps.wsgi:application -w 2 -b :8000
    depends_on:
      - mysql

According to here -- Docker-Compose persistent data MySQL, the docker volumes get stored at /var/lib/docker/volumes, but that path doesn't exist on my system ...

localhost:maps davea$ ls /var/lib/docker/volumes
ls: cannot access '/var/lib/docker/volumes': No such file or directory

Where on my system is this MySql volume getting stored?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • in the MySQL service you are mapping the db volume under my-db folder which exists in the same directory as your docker-compose file – Thamer Feb 24 '20 at 20:18

1 Answers1

0

docker is not running natively on mac. instead, it uses some kind of Linux simulation see this. You can find the path /var/lib/docker/volumes inside the containers. If you want to have access from Mac to the volume, you can switch the volume to use local files with the below change, but make sure that the LOCAL_PATH is created in your machine.

- ${LOCAL_PATH}:/var/lib/mysql
Al-waleed Shihadeh
  • 2,697
  • 2
  • 8
  • 22