Reputation: 1796
I've got some Python app which used bind mounts to mount code into container, so I don't have to build container on each code change, like this:
app:
volumes:
- type: bind
source: ./findface
target: /app/findface
And it was working fine. But now I also want to bind my startup script, which is invoked from Dockerfile:
app:
volumes:
- type: bind
source: ./findface
target: /app/findface
- type: bind
source: ./startup.sh
target: /app
And this one just doesn't bind. There is an actual file in the host filesystem, but when I build the container it can't find it:
Step 7/8 : RUN chmod +x startup.sh
---> Running in ecaae384b6e5
chmod: cannot access 'startup.sh': No such file or directory
ERROR: Service 'app' failed to build: The command '/bin/sh -c chmod +x startup.sh' returned a non-zero code: 1
What am I doing wrong?
Dockerfile itself:
FROM jjanzic/docker-python3-opencv:latest
ENV PYTHONUNBUFFERED=1
RUN pip install --no-cache-dir gunicorn[eventlet]
WORKDIR /app
COPY ./requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN chmod +x startup.sh
CMD "./startup.sh"
Upvotes: 0
Views: 810
Reputation: 59896
Base on your comment, then you do not need set permission at build stage as the file is not exist at build time, if you do not want to copy at build stage, set permission on the host to make executable and then bind with docker run command or as per the yml config that you mentioned.
CMD "/app/startup.sh"
for example
docker run -it --rm -v $PWD/startup.sh:/app/startup.sh my_image
Upvotes: 2