(I'm not deeply experienced with docker
, fwiw)
I have a django appication I'm containerizing. Currently when I run docker-compose up
the redis
service starts up, but api
exits with error: ERROR: for api Cannot start service api: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \\"python3\\": executable file not found in $PATH": unknown
#docker-compose.yaml
version: '3'
services:
redis:
image: redis
ports:
- 6379
api:
build:
context: ../backend/
dockerfile: ../backend/Dockerfile
env_file: .env
volumes:
- ../backend:/code/
ports:
- "8001:8001"
depends_on:
- redis
with
#../backend/Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
ADD . /code/
WORKDIR /code/
RUN pip install -r requirements.txt
CMD python manage.py runserver
and
#./.env
DJANGO_SETTINGS_MODULE=backend.settings.dev
DJANGO_SECRET_KEY=<redacted>
SENTRY_URL=<redacted>
I've also, based on other issues, tried using both CMD
and RUN
with their differing argument types, ie in the existing shell and without, but the output hasn't changed.
I should also acknowledge that it's possible I'm not restarting actually catching the updates to docker-compose.yaml
or Dockerfile
. My workflow has been $ docker-compose down
followed by $ docker-compose up
.
EDITS:
@henrik-andersson pointed me in the right direction. The proximate cause of the error is the fact that the image itself was not built, so the executable python
didn't exist. the command I needed to run was docker-compose up --build
docker-compose up --build
showed that the images were not built. This was fixed by moving the docker-compose.yaml
file to the parent directory st the Dockerfile
for each service could be accessed properly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.