0

I have a problem with a docker container. I have a solution in C#, this solution needs a .config file at start and this file is always in C:\DBConnection\DBConnection.config. Now I'm wondering if it's possible, when I start a cointainer with run command, to take this file from the host C:\DBConnection directory and bring it in container, so the solution can read it. Sorry if I'm not clear, feel free to ask for more information if you need. Thanks a lot in advance.

Rob None
  • 479
  • 2
  • 9
  • 22
  • You could mount that file inside the container in a path which you can specify and your program running inside the container can read the file. – bg2094 Oct 17 '19 at 15:03
  • Can you tell me how you are running the container. I mean is it using just `docker` or are you using `docker-compose`. – bg2094 Oct 17 '19 at 15:10
  • I'm running the container with docker (I'm newbie of docker still didn't approach to docker-compose world). – Rob None Oct 17 '19 at 15:13
  • And this container is already built and you cannot or do not want to rebuild it again ? – bg2094 Oct 17 '19 at 15:16
  • You can use `docker cp` to copy files to your container. Refer answer: https://stackoverflow.com/questions/22907231/copying-files-from-host-to-docker-container – bg2094 Oct 17 '19 at 15:22
  • I will give you more details. I created a solution (webAPI), then I created a private registry on my PC. After i made the solution, I publish the image on my private registry with the Visual Studio 2019 tool. So, I want others people able to download my image and start it in a cointainer with docker run. But this application needs for working to read this config file, and people will knows that they have to create a folder C:\DBConnection with a specific DBConnection.config file before they give the run command. But how i can make the container bring this file with him after the run command? – Rob None Oct 17 '19 at 15:25
  • Okay let me see if I got it right. You built a `docker image`. Anyone who wants to run this `image` needs a `DBConnection.config` in their `C:\DBConnection` path in the host machine ( which is the machine they are running the `docker` from). Now you want this `config` file to be copied inside the `container` from `C:\DBConnection` in the host machine while the `docker run` command is run ? – bg2094 Oct 17 '19 at 15:38
  • Exactly, you got it. – Rob None Oct 18 '19 at 07:02
  • Why not put the `config` file inside the `image` which you are giving to the user ? Unless you want the file in the host machine and the container to be linked. Do you want it to be linked ? As in if you change the `config` in the host machine, the `config` file will change in the container. – bg2094 Oct 18 '19 at 07:30
  • I would have a configurable file from other users before starting the container. – Rob None Oct 18 '19 at 13:10
  • Alright, then you can `mount ` the config file into the `container` as you run the command. So it's available from outside. – bg2094 Oct 18 '19 at 13:13

0 Answers0