Docker Community Forums

Share and learn in the Docker community.

Map container directory to Windows host directory

Hi,
I am using Docker Desktop Community V2.2.0.4 (43472), Channel stable. It is running on my Windows 10 V1903 Build 18362.720 host.

I am running a Mono Image, that is running my .NET application. The .NET application is writing files to a configured directory.
I want that the configured directory is mapped to my Windows 10 host.
This means, if the .NET application is creating a file, this file should created on my Windows 10 host.

Well, I am using Docker-Compose. In my Docker-Compose file I have the following volume defined:
volumes:

    • ./dockerDocumentPath:/usr/data*
      The .NET Application is using the “/usr/data” path to write the files.
      The “./dockerDocumentPath” is a folder in my Windows 10 host. It is a subfolder from the folder, that contains the Docker-Compose file.

The application seems to work correctly. I can add files and open the added files.
The “dockerDocumentPath” directory is empty.
Where do I find my files?
In the Docker-Settings I activated “file sharing” for all my drives.
Thanks,
Christian

What’s the meaning of this asterisk?

Hi,
thanks for your help.
The asterisk was accidentally added. Please ignore it
./dockerDocumentPath:/usr/data
Is the mapping eventually applied to the Hyper-V image, that is created by Docker for Windows?

I think you didn’t get any help yet. :wink: It would be better if you don’t explain what you are doing, but show it. How does your compose file look like (and please format it as code), what command do you use to start the containers?

Hi,
this is my Docker-Compose file:

version: '3.6'
services:

 mysolr:
  container_name: mysolr
  image: solr:7.7.2
  ports:
   - "8983:8983"
  entrypoint:
   - bash
   - "-c"
   - "precreate-core myCore; exec solr -f"
  networks:
   - app-net

 myDotNet:
  environment:
   serversettings: "{\"Settings\":\"PathForDocuments\":\"/usr/novi\"}"
  build: ./ #builds the .NET image as defined in "Dockerfile"
  ports:
   - "49172:49172" 
   - "9898:9898" 
  depends_on:
   - mysolr # Inform docker to create a "solr" container first
  networks:
   - app-net
  volumes:
   - ./dockerDocumentPath:/usr/novi 
networks:
 app-net:
 
volumes:
 v:

I am starting the containers with the following command:

docker-compose -f myDockerCompose.yml up

Regards,
Christian

It is still not clear to me what you make, I don’t know what this Dockerfile is doing. You should start with something simple and mount a folder into the container that contains some files. Then go into the container and list its content. If it’s empty, you have to fix this. The reason could be that you are on a drive that is not available to Docker, or that your firewall blocks the Docker network.