Why would Docker be unable to find a file on the host filesystem, when it definitely exists?
I have these lines in my Dockerfile that make a directory in the image and copy a file into it from the host:
RUN mkdir -p /root/somedir
COPY /var/lib/www-data/somedir/somefile /root/somedir/
If I run ls /var/lib/www-data/somedir/somefile on the host, I see the file definitely exists, with permissions that allow anyone to access it.
However, when I try to build my image, Docker fails with the error:
Service 'app_test' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder102437525/var/lib/www-data/somedir/somefile: no such file or directory
I'm building using docker-compose, and my compose file is simply:
version: "3.6"
services:
app_test:
build:
context: ..
dockerfile: test/Dockerfile
volumes:
- /dev/shm:/dev/shm
Why is Docker trying to copy from some temp directory under /var/lib/docker, and why can't it find my file?