If COPY is not in the current directory,docker will show that it cannot find .
cat Dockerfile
FROM nginx:latest
COPY /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
docker build .
Sending build context to Docker daemon 16.38kB
Step 1/2 : FROM nginx:latest
---> ed21b7a8aee9
Step 2/2 : COPY /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
COPY failed: stat /var/lib/docker/tmp/docker-builder665445903/etc/nginx/nginx.conf.bak: no such file or directory
Why does docker look for the /var/lib/docker directory?
If the file is in the current directory, docker build is working.
cat Dockerfile
FROM nginx:latest
COPY /etc/nginx/nginx.conf /etc/nginx/nginx.conf
docker build .
Sending build context to Docker daemon 16.38kB
Step 1/2 : FROM nginx:latest
---> ed21b7a8aee9
Step 2/2 : COPY nginx.conf.bak /etc/nginx/nginx.conf
---> Using cache
---> b642c4e0a25f
Successfully built b642c4e0a25f