I am trying to make my Django redis celery project on with docker-compose
, but there is no way it is starting. Here is the docker-compose file
version: "3.9"
services:
db:
container_name: my_table_postgres
image: postgres
ports:
- 5432/tcp
volumes:
- my_table_postgres_db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=my_table_postgres
- POSTGRES_USER=dev
- POSTGRES_PASSWORD=Ieyh5&RIR48!&8fc
redis:
container_name: redis
image: redis
my_table:
container_name: my_table
build: .
command: python manage.py runserver 0.0.0.0:5000
volumes:
- .:/api
ports:
- "5000:5000"
depends_on:
- db
- redis
celery:
restart: always
build:
context: .
command: ['celery', '-A', 'mytable', '-l', 'INFO']
volumes:
- .:/api
container_name: celery
depends_on:
- db
- redis
- my_table
volumes:
my_table_postgres_db:
redis_data:
And that is the Dockerfile:
FROM python:3.11
# Managing user
RUN mkdir /mytable
RUN useradd -ms /bin/bash devuser
USER devuser
COPY . /mytable
WORKDIR /mytable
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
COPY --chown=devuser:devuser requirements.txt requirements.txt
RUN pip install --user --default-timeout=1000 --upgrade pip
RUN pip install --user --default-timeout=1000 -r requirements.txt
EXPOSE 5000
#ENV PATH="/home/devuser/.local/bin"
COPY --chown=devuser:devuser . .
# Run manage.py runserver when the container launches
CMD ["python3", "manage.py", "runserver"]
And here is the full error that I get when I try to run docker-compose up --build
Recreating eda7aad3f246_celery ... error
ERROR: for eda7aad3f246_celery Cannot start service celery: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "celery": executable file not found in $PATH: unknown
ERROR: for celery Cannot start service celery: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "celery": executable file not found in $PATH: unknown
ERROR: Encountered errors while bringing up the project.
Does someone know how to fix it? I read several similar questions on this forum, but the only thing that I changed was passing from the one line command, to the parenthesis command in docker compose, and that did not work.
Any suggestion? Thank you
i faced the same issue and resolved it like this:
$docker compose up -d --build
$docker compose up