I want to mount /usr/local/bin/ to my host machine from docker python:3. The reason I want to do this is because I want my PyCharm Community edition to be able to use my docker interpreter for my IDE.
Here is my docker compose file:
version: '3.8'
services:
db:
image: mysql:8.0
cap_add:
- SYS_NICE
restart: always
environment:
- MYSQL_DATABASE=mydb
- MYSQL_ROOT_PASSWORD=root
ports:
- '3306:3306'
volumes:
- db:/var/lib/mysql
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
web:
build: .
command: python app/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code/app
- ./python-env:/usr/local/bin/
ports:
- "8000:8000"
environment:
- DB_NAME=mydb
- DB_USER=root
- DB_PASSWORD=root
depends_on:
- db
volumes:
db:
driver: local
The problem is this line:
- ./python-env:/usr/local/bin/
The error is:
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "python": executable file not found in $PATH: unknown
I have tried to setup a symlink in my docker build file, to /usr/local/bin and mount that directory instead but I get no success. Anyone got any ideas on the problem?
The bin folder contains essential executables for the OS. When you mount your own volume python-env to the dockers user/local/bin, it is unable to find any required files in the mounted folder (python-env) and gives the error.
If your goal is to share a Python environment between the host and container, you can