I have a folder ./lib/my-python-library
that contains a python package on the host system:
./Dockerfile
./lib/my-python-library/setup.py
my_python_library
...
Now, I copy that path into my docker container with
COPY ./lib/my-python-library /my-python-library
RUN cd /my-python-library && pip install -e .
Which works. I can now import the library when I execute bash and run python -c 'import my_python_library
.
However, I want to be able to modify the code on the fly without having to restart the container, which usually works. However, when I mount that specific library directory with docker-compose:
docker-compose.yml (snippet):
services:
web:
build: .
env_file:
- ./.env
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./app/:/app/
- ./lib/my-python-library:/my-python-library/
And run the container, docker-compose creates an empty directory named my_python_library
in the root of my project host and mounts that new empty directory. Instead, it should mount my-python-library
.
Is that a general limitation of docker-compose
that directories with dashes are not mountable or am I doing something wrong?
Update:
It seems docker-compose is unable to mount the dashed . When I rename the directory on the host to my_python_library and make the corresponding changes in the docker-compose.yml
This works:
./lib/my_python_library/setup.py
my_python_library
...