Issues with Mounting Files and Directories in Docker Compose

Hi,

Docker version 23.0.3, build 3e7cbfd
Docker Compose version v2.17.2
Docker Engine v20.10.24
Ubuntu 22.04.2 LTS 64bit as a VM in VMware Player

I have been pulling my hair out trying to understand why I cannot get this working. Within my docker-compose.yml file, here is the section that I am interested in:

grafana:
    restart: unless-stopped
    container_name: obmp-grafana
    image: grafana/grafana:8.2.6
    ports:
      - "3000:3000"
    volumes:
      - /var/openbmp/obmp-grafana/provisioning:/etc/grafana/provisioning/
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=openbmp
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_USERS_HOME_PAGE=d/obmp-home/obmp-home
      - GF_INSTALL_PLUGINS=agenty-flowcharting-panel,grafana-piechart-panel,grafana-worldmap-panel,grafana-simple-json-datasource,vonage-status-panel

Running docker compose with:

OBMP_DATA_ROOT=/var/openbmp docker compose -f ./docker-compose.yml -p obmp up -d

Successfully mounts the provisioning directory, which I can see in the “Files” section of the Grafana container in Docker Desktop, but the datasources directory is empty. This shouldn’t be the case, as there is a .yml file in there on my host machine.

Additionally, if I was to modify the volumes: such that it points directly to the the openbmp-ds.yml file, then it mounts as a directory?

I have read that this can happen if the file doesn’t exist on the host machine, but I am 100% positive that it does, and it is most certainly not a directory:

openbmp@openbmp-VM:/var/openbmp/obmp-grafana/provisioning/datasources$ ls -l
total 4
-rw-rw-r-- 1 openbmp root 1323 Apr 6 11:52 openbmp-ds.yml

I have also tried:

  • different versions of Graphana
  • trying with the legacy docker-compose
  • trying with ${PWD} in the path
  • trying with the long hand syntax for volume instead
  • manually importing the .yml file via the Files within Docker Desktop - which works, and it is recognized

I am so frustrated and out of ideas. I’d appreciate any assistance.

Thanks!

For anyone who may stumble upon this, I finally figured it out.

Not sure about Windows/Mac, but within Ubuntu, you need to go into Docker Desktop → Resources → File sharing and add the path you are trying to mount. By default, /home was only selected. Applying and restarting Docker did the trick.