I have a .net Core web Api having configurations files under a folder called Config. I created the image and a container from it, and I correctly see using the terminal, that the container contains the folder and the configuration files inside.
My problem is that so far I couldn't find a way to create the same container mounting/binding the Config folder to a physical path, following the requirements:
1) Mount Config folder to a specific host location
2) On container creation, the Config folder should be filled with the files in the image
3) On container creation, override any existing file already present in the folder with those in the image
4) Be able to customize the config files in the folder from the host
My create command:
docker --tls -H="$containerUrl" `
create `
--hostname $hostname `
--name $containerName `
--mac-address=$containerMacAddress `
--ip $containerIpAddress `
--net "bridged-network" `
--workdir '/app' `
--mount type=bind,src=$configVolumePath,target=/app/Config `
--publish "0.0.0.0::80" `
-t `
-i $imageName":"$script:buildversion
Using --mount with type bind, as specified in the documentation, if there is any file in the folder, those hare hidden from within the container and the application will see the deployed files. The problem of this solution is that I cannot update the files in the config folder from the host.
Now, removing type=bind I get the same result, and it is confusing.
I tried to use volume --volume $configVolumePath":/app/Config:rw", but doing so the pre exising files in the host directory are not overridden and those are the one that will be used within the container.
Additional notes, I don't specify anything in the Dockerfile or compose related to volume mounting, and I didn't try to create a volume to then use it as a source, but I don't think that would make a difference.
The container server is running on a NAS and this is the version:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: 781516c
Built: Thu Aug 3 16:04:05 2017
OS/Arch: linux/amd64
Clearly I'm missing something and I have to learn more about docker, can anyone help?
My references:
1) https://docs.docker.com/engine/admin/volumes/bind-mounts/
2) https://docs.docker.com/engine/admin/volumes/volumes/