Docker Community Forums

Share and learn in the Docker community.

Docker Cloud can't find file in source during build process

build
automatedbuilds
dockercloud

(Zehirsch) #1

My Dockerfile looks like this:

FROM postgres:9.6

COPY ./compose/production/postgres/backup.sh /usr/local/bin/backup
RUN chmod +x /usr/local/bin/backup

COPY ./compose/production/postgres/restore.sh /usr/local/bin/restore
RUN chmod +x /usr/local/bin/restore

COPY ./compose/production/postgres/list-backups.sh /usr/local/bin/list-backups
RUN chmod +x /usr/local/bin/list-backups

I have set up an automated build in Docker Cloud. However, when I test it, I get the following error:

Step 2/7 : COPY ./compose/production/postgres/backup.sh /usr/local/bin/backup
COPY failed: stat /var/lib/docker/tmp/docker-builder385337574/compose/production/postgres/backup.sh: no such file or directory
ERROR: Build failed: COPY failed: stat /var/lib/docker/tmp/docker-builder385337574/compose/production/postgres/backup.sh: no such file or directory
ERROR: Build failed with exit code 2
ERROR: Build in 'master:/compose/production/postgres/Dockerfile' (6bfe5460) failed in 0:03:12

I have checked my source, and backup.sh exists in my source at compose/production/postgres/backup.sh, right where I expect it to be.

Does anyone know why the build system isn’t able to locate this file? I assume that at some point it is copying my repository to /var/lib/docker/tmp/docker-builder385337574/, and but it can’t find backup.sh in there…


(Sam) #2

and that is relative to the CURRENT HOST directory during the build… ?


(Zehirsch) #3

@sdetweil Yes, I think so. The compose/ directory is in my project’s root, so if Docker Cloud is moving my project’s root to /var/lib/docker/tmp/docker-builder385337574/, compose/ and everything in it should should be in the right place.


(Sam) #4

how did u get the files in compose/ etc… from your host to dockercloud disk?


(Zehirsch) #5

@sdetweil Docker Cloud is running an automated build from my Bitbucket repo. In the automated build settings, I set the Dockerfile location to compose/production/postgres/Dockerfile. I left Build Context blank, since the Dockerfile path is relative to the root.

Let me know if that doesn’t answer your question…


(Sam) #6

ok, as I understood docker build, all resources MUST BE from the current folder DOWN.

if the Dockerfile folder is placed as currrent, then the copy path is wrong

try doing this in the dockerfile before the copy

RUN ls -laF

to see where the current folder is…


(Zehirsch) #7

The output from RUN ls -laF looks like this:

Step 2/8 : RUN ls -laF
---> Running in 5ea70b1af57c
total 76
drwxr-xr-x 51 root root 4096 Jan 9 21:37 ./
drwxr-xr-x 51 root root 4096 Jan 9 21:37 ../
drwxr-xr-x 2 root root 4096 Dec 12 06:07 bin/
drwxr-xr-x 2 root root 4096 Nov 19 15:32 boot/
drwxr-xr-x 5 root root 340 Jan 9 21:37 dev/
drwxr-xr-x 2 root root 4096 Dec 12 06:06 docker-entrypoint-initdb.d/
lrwxrwxrwx 1 root root 34 Dec 12 06:07 docker-entrypoint.sh -> usr/local/bin/docker-entrypoint.sh*
-rwxr-xr-x 1 root root 0 Jan 9 21:37 .dockerenv*
drwxr-xr-x 78 root root 4096 Jan 9 21:37 etc/
drwxr-xr-x 2 root root 4096 Nov 19 15:32 home/
drwxr-xr-x 11 root root 4096 Nov 27 2014 lib/
drwxr-xr-x 2 root root 4096 Dec 10 00:00 lib64/
drwxr-xr-x 2 root root 4096 Dec 10 00:00 media/
drwxr-xr-x 2 root root 4096 Dec 10 00:00 mnt/
drwxr-xr-x 2 root root 4096 Dec 10 00:00 opt/
dr-xr-xr-x 123 root root 0 Jan 9 21:37 proc/
drwx------ 2 root root 4096 Dec 10 00:00 root/
drwxr-xr-x 6 root root 4096 Dec 12 06:06 run/
drwxr-xr-x 2 root root 4096 Dec 10 00:00 sbin/
drwxr-xr-x 2 root root 4096 Dec 10 00:00 srv/
dr-xr-xr-x 13 root root 0 Jan 9 21:37 sys/
drwxrwxrwt 2 root root 4096 Dec 12 06:07 tmp/
drwxr-xr-x 25 root root 4096 Dec 10 00:00 usr/
drwxr-xr-x 23 root root 4096 Dec 10 00:00 var/
---> d65f52bc36fa

It seems to indicate that var/ is a directory, which would line up with where it’s looking for that file:

Step 3/8 : COPY ./compose/production/postgres/backup.sh /usr/local/bin/backup
COPY failed: stat /var/lib/docker/tmp/docker-builder123732812/compose/production/postgres/backup.sh: no such file or directory

(Sam) #8

yeh… now… how did the file GET there… where is the pull from the bitbucket repo to /var/lib/…/compose/etc…


(Zehirsch) #9

Docker Cloud handles all that behind the scenes. It is part of their automated build system. You just connect your Bitbucket account, identify which branch you want to monitor (in my case, master), and enter the location of the Dockerfile within the repo. Docker Cloud then waits for any pushes to that repo/branch. When there is a push, it starts the build automatically, resulting the error I showed above.

I don’t have any control over where or how it moves files from my repo to /var/lib/docker/tmp/docker-builder123732812/ before beginning the build process.


(Zehirsch) #10

Here is an article about it: https://docs.docker.com/docker-cloud/builds/automated-build/


(Zehirsch) #11

Ugh, I fixed it, and it was such a stupid thing.

Build Context was left blank, but needed to be set to /— the directory root.

Thanks for spending time looking into it, @sdetweil. I appreciate it!


(Sam) #12

cool… things you learn!.. thanks for the feedback