I need to share a folder from my OSX machine with a running Docker container, but I can't find how to do it. Here's a working Docker-compose file:
version: '2'
services:
mariadb:
image: 'bitnami/mariadb:10.3'
environment:
- MARIADB_ROOT_PASSWORD=bitnami
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- 'mariadb_data:/bitnami'
phpmyadmin:
image: 'bitnami/phpmyadmin:4'
ports:
- '8081:80'
- '4430:443'
depends_on:
- mariadb
volumes:
- 'phpmyadmin_data:/bitnami'
moodle:
image: 'bitnami/moodle:3'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '80:80'
- '443:443'
volumes:
- 'moodle_data:/bitnami'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
phpmyadmin_data:
driver: local
moodle_data:
driver: local
This file correctly starts 3 Docker containers, 1 for Moodle, 1 for MariaDb and 1 for Phpmyadmin.
What I need to do now is to share the content of a local folder with a folder inside the Moodle container. But I can't figure out how to change the Volumes key to reflect that. I tried with a mapping like:
moodle_data:
- moodle_data:/Users/macbook/Code/Php/moodle-docker/moodle/Users/macbook/Code/Php/moodle-docker/moodle
But it didn't work.. what am I doing wrong here? Thanks in advance to anybody who can help!
You need to map your host_folder with your container_folder using host_folder:container_folder. As mentioned on the comments:
moodle:
image: 'bitnami/moodle:3'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '80:80'
- '443:443'
volumes:
- /Users/macbook/Code/Php/moodle-docker/moodle:/bitnami/gatto
- moodle_data:/bitnami
depends_on:
- mariadb
Remember: Your folder on host_folder must be acessible by docker daemon