moby: COPY fails intermittently no such file or directory

Description COPY command in Dockerfile fails intermittently with no such file or directory

Steps to reproduce the issue:

  1. docker build -t dthompson55/mosquitto .
  2. Dockerfile contains: COPY docker-entrypoint.sh /
  3. Filesystem contains: -rwxrwxr-x 1 dant dant 30 Oct 3 11:50 docker-entrypoint.sh

Describe the results you received: —> 7be6a723492a Step 5 : COPY docker-entrypoint.sh / stat /var/lib/docker/aufs/mnt/5c714d1adb30f1366a6d12a49bc6529b88cb2887e71cf640a5daa5e989dac4ea/docker-entrypoint.sh: no such file or directory

Describe the results you expected:

I expected it to copy the file into the build context.

Additional information you deem important (e.g. issue happens only occasionally):

The build works a few times, and then fails. Once it fails I can’t get it to work again. If I reinstall everything on a clean ubuntu image then it works again, for a while.

Output of docker version:

docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:33:38 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:33:38 2016
 OS/Arch:      linux/amd64

Output of docker info:

docker info
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 4
Server Version: 1.12.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 6
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: host null bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-31-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.5 MiB
Name: dant-VirtualBox
ID: WMSY:GBWI:IODG:ZZJK:2UVM:HB7D:PRRW:R6HZ:TIFO:6PVL:JANB:EP5N
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: dthompson55
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8

Additional environment details (AWS, VirtualBox, physical, etc.):

VirtualBox running Ubuntu client

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (11 by maintainers)

Most upvoted comments

I hit this as well, restarting the daemon fixed things…

(not that that is an ok fix, but it is a workaround 😃

This also occurs in combination with GitHub, Dockerhub and automated build. Also see this linke Docker Forums link

Also see: #27233

Keep in mind that source paths in COPY and ADD Dockerfile instructions are relative to the build context. So if you run

docker build -t foo .

The trailing . indicates the current directory; that directory is used as build-context, and sent to the docker daemon to use for the build.

What does your local directory look like? COPY /work/local.txt looks for a file named local.txt in the current directory, so if it’s missing, it fails:

$ mkdir repro-27134 && cd repro-27134

$ cat > Dockerfile -<<EOF
FROM httpd:2.4
COPY /work/local.txt /usr/local/apache2/htdocs/
EOF

$ docker build -t repro-27134 .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM httpd:2.4
 ---> b1e597b50dd7
Step 2/2 : COPY /work/local.txt /usr/local/apache2/htdocs/
COPY failed: stat /var/lib/docker/tmp/docker-builder333585158/work/local.txt: no such file or directory

However, after creating the file;

$ mkdir work
$ echo "foobar" > work/local.txt

Building works;

$ docker build -t repro-27134 .

Sending build context to Docker daemon  3.584kB
Step 1/2 : FROM httpd:2.4
 ---> b1e597b50dd7
Step 2/2 : COPY /work/local.txt /usr/local/apache2/htdocs/
 ---> 1759bd85fdf5
Removing intermediate container ad7b5df444f8
Successfully built 1759bd85fdf5
Successfully tagged repro-27134:latest