Reputation: 33
I create a docker image in order to set a python code with schedule,so I use python-crontab
module, how can i solve permission denied problem?
Ubuntu 16.04.6 LTS python 3.5.2
I create sche.py
and it can trigger weather.py
,
it is success in local,but it can't package to docker image
```
#dockerfile
FROM python:3.5.2
WORKDIR /weather
ENTRYPOINT ["/weather"]
ADD . /weather
RUN chmod u+x sche.py
RUN chmod u+x weather.py
RUN mkdir /usr/bin/crontab
#add due to /usr/bin/crontab not found
RUN pip3 install python-crontab
RUN pip3 install -r requirements.txt
EXPOSE 80
#ENV NAME World
CMD ["sudo"]
#CMD ["python", "sche.py"] ## build step fail
ENTRYPOINT ["python","sche.py"]
## can build same as "RUN ["python","sche.py"] "
```
I expect it can run in docker image rather than each python file only.
Upvotes: 3
Views: 1100
Reputation: 1267
Try USER root
after FROM python:3.5.2
line.
Remove CMD ["sudo"]
and ENTRYPOINT ["/weather"]
Replace RUN mkdir /usr/bin/crontab
RUN apt-get update \
&& apt-get install -y cron \
&& apt-get autoremove -y
Upvotes: 1