0

This might be too general question, unfortunately I was not able to find the right answer. I would like to dockerize my aspn.net mvc application. I have method that scans local folder for files

C:\input_data

The path is passed to a method and everything works great.

When you create an image and container you will have to map this directory as volume

docker run -v c:/input_data:/data

I understand that inside the container you can use only /data. How /data will be passed to the method as a valid folder path? In addition the path is stored in settings table, so C:\input_data will be passed to a method all the time and this method would expect C:\input_data as a valid path.

How is this resolved? Do I have to provide instructions to docker how to resolve this mapping between /data and C:\input_data?

Thanks

rafaelncarvalho
  • 729
  • 7
  • 26
tipitoe
  • 11
  • 2
  • 8
  • Which image are you using? Can you add your Dockerfile to the question? – rafaelncarvalho Mar 14 '19 at 19:45
  • Sorry, I did not create Dockerfile yet. I'm just trying to wrap my head around this internal working of Docker/container. I understand that Dockerfile contains the mapping to host folder and alias that we would like to use internally. – tipitoe Mar 14 '19 at 19:58
  • I will use Microsoft .net core image – tipitoe Mar 14 '19 at 19:59
  • Possible duplicate of [How to mount a host directory in a Docker container](https://stackoverflow.com/questions/23439126/how-to-mount-a-host-directory-in-a-docker-container) – David Kamer Mar 14 '19 at 20:32
  • Don't agree. This is not duplicate. The post you mentioned is about mapping volume. In this case how do you pass mapped host folder to a method? You can pass /data as input folder to a method. Settings table has folder path defined by a user. Unless Docker somehow magically resolves host folder -> /data -> C:\input_data. It looks like something is missing. – tipitoe Mar 14 '19 at 21:01

1 Answers1

0

You can set an environment variable on Dockerfile to set the path to /data.

ENV METHOD_PATH="/data"

And change your configuration to use the env METHOD_PATH

Doing this, your app will always use the path /data inside the Docker

In this link you can find more info in how to use environment variables with ASP.NET: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.2

rafaelncarvalho
  • 729
  • 7
  • 26