I get an error when I try to mount it in a container and use it in the usual way.
$ python -m venv .venv
Error: [Errno 71] Protocol error: 'lib' -> '/app/.venv/lib64'
Caused by issuing a symlink when using venv and sharing it when mounting locally
Use How to exclude some when mounting Volume with Docker to exclude it from the mount with the symbolic link.
In the command below, a symbolic link will be attached under ** {working directory} /. Venv / **, so exclude it.
python -m venv .venv
Part of docker-compose.yml
version: "3.7"
services:
app:
...
volumes:
- {Working directory}/.venv/
docker-compose.yml
Whole sample
version: "3.7"
services:
app:
build: ./app/
working_dir: /app
volumes:
- ./app:/app:cached
- /app/__pycache__
- /app/.venv/
- /app/.tox/ #for tox
environment:
- FLASK_ENV=development
ports:
- "5000:5000"
Recommended Posts