I use docker-compose
for running my containers in docker
. I have two services - one of celerybeat
and other the web
(I have many others but considering only these services because they contain my problem).
docker-compose.yml
file looks like this:
.
.
.
celerybeat:
image: web-image
volumes:
- /home/ubuntu/celerybeat:/code/celerybeat
command: >
/bin/ash -c "su -m celery -c 'celery -A <application_here> beat -s /code/celerybeat/celerybeat-schedule'"
web:
image: web-image
volumes:
- /home/ubuntu/celerybeat:/code/celerybeat
command: >
<some_command_to_run_server>
In my Dockerfile
I have added these commands for proper permissions
RUN mkdir celerybeat
RUN touch celerybeat/celerybeat-schedule
RUN chown -R celery:celery celerybeat
Note: In my compose file structure written above I have provided volume mounts for both containers (but actually I am using one at a time), for the ease of not writing the compose files again and again.
The problem is actually here only. Technically the volume mount should be provided only in the celerybeat service. When I write volume mount for celerybeat-schedule
in the celerybeat docker service I get permission denied
. Whereas when I write the volume mount command in the web service celerybeat service starts happily. What is happening here can anyone explain me? I need a fix for this.