Home > Software design >  mounting a drive to a docker container results in an empty folder?
mounting a drive to a docker container results in an empty folder?

Time:11-16

I am using docker to run a django application and am trying to mount a folder on my local system, however when checked through bash, the folder inside the container is empty?

My docker-compose looks like:

web:
    restart: on-failure
    working_dir: /example_docker/
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - "./example_docker:/example_docker"
      - "/mnt/c/Users/liam.obrien/Desktop/Scratch Python:/example_docker/local1:rw"
    ports:
      - "8000:8000"
    depends_on:
      - db
      - redis
      - channels
    env_file:
      - .env

The volume Example docker mounts as expected however i cant seem to get the container to show the files in the folder that im using the absolute folder path for.

No idea why this is, do i need to copy the path in my Dockerfile?

CodePudding user response:

it looks like you are mounting a folder inside of a folder thats already on your computer? instead of mounting the Scratch Python inside a folder inside example_docker/local1 try mounting it somewhere else as that may cause problems (potentially duplicating your folders)

also if you are mounting from a windows system you can use the full windows path instead of the wsl path, for an example see: Mounting a network drive with docker compose on Windows 10

This should make things a little simpler as you dont have to reference the wsl file configuration

  • Related