Reputation: 566
I mount a host file into a docker container, and the mounted file becomes a directory inside the container. That's how I run it:
$ docker run --name <containername> -it -d -v /home/core/account_config.py:/code/account_config.py <imagename>
Inside the container:
# ls -la
-rw-r--r--. 4 root root 0 Nov 6 10:25 __init__.py
drwxr-xr-x. 2 root root 4096 Nov 6 10:59 account_config.py
....
The file (in the host file system) is still a perfectly ok python file.
The source code is added into /code
during build. The corresponding line in my Dockerfile is:
ADD ./code /code
I want to be able to change the content of config file without rebuilding the image, so I want mount it later. What went wrong and how can I fix this?
Upvotes: 3
Views: 1595
Reputation: 5432
If you want to be able to modify a file on the host machine and have changes reflect within a container, you should mount the volume via -v HOST_PATH:CONTAINER_PATH
when you run
the container.
Upvotes: 0
Reputation: 566
As it happens with (almost) every weird issue, turned out that this one has a very simple solution.
The path to host file contained a typo, so the docker automatically created a directory in this path, and mounted it to the container.
Upvotes: 2