Here is my Dockerfile
# Pull node docker image
FROM python:3.7-buster
RUN mkdir -p /home/deployment && chown -R root:root /home/deployment
WORKDIR /home/deployment
COPY weldTrace-linux ./
COPY verified.json ./
COPY flaskapp ./
My docker-compose.yml
version: "1.0"
services:
mongo:
image: mongo:4.4.14
command: mongod --port 27018
ports:
- 27018:27018
volumes:
- ${DBPATH}:/data/db
web:
build: .
ports:
- 3000:3000
command: ./app-linux
depends_on:
- mongo
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ${MEDIAPATH}:/data/media
flask:
image: python:3.7-buster
ports:
- 5000:5000
# volumes:
# - ${PIPPATH}:/usr/local/lib/python3.7/site-packages
# - ./flaskapp:/home/deployment/flaskapp
# working_dir: /home/deployment/flaskapp
command: flask run
# depends_on:
# - requirements
# requirements:
# image: python:3.7-buster
# volumes:
# - ${PIPPATH}:/usr/local/lib/python3.7/site-packages
# - .:/home/deployment/flaskapp
# working_dir: /home/deployment/flaskapp
# command: pip install -r requirements.txt
volumes:
data:
external: true
pip37:
external: true
and my PIPPATH=D:Programmingpip37
When I execute docker-compose up
, I end up getting the following error
Error response from daemon: failed to create shim: OCI runtime create
failed: container_linux.go:380: starting container process caused:
exec: "flask": executable file not found in $PATH: unknown
Any idea/suggestion about how to fix this? Since Dockerfile base in mongo I could not use RUN command to install any python, pip and its packages.
2
Answers
You need to install Flask in your dockerfile:
Like others have pointed out, the
python:3.7-buster
image doesn’t come withflask
installed. Soflask
needs to be installed before theflask run
command is executed. For the setup you have, this can be done in one of two ways:Option 1:
As the base image in the
Dockerfile
is alsopython:3.7-buster
, an instruction can be added to installflask
, like Kesha suggested. A slimmed down/customized version of theDockerfile
below:Then in the
docker-compose.yml
, the image built for serviceweb
can be reused for serviceflask
. Slimmed down compose file below:The
flask run
command executes without any errors becauseflask
has already been installed into the custom docker imageOption 2:
Continue using
python:3.7-buster
as the image for serviceflask
. In that case, after starting the service, thepip install flask
command needs to be executed before theflask run
command. Modified compose file below: