COPY failed when building with --state flag
when running img build -s <folder> -f Dockerfile -t <tag> ., it failes on COPY command.
once -s <folder> is taken, it can build successfully.
#11 [compilation 4/8] COPY . /go/src/github.com/
#11 digest: sha256:9f9d8f9ec942454a48bae9f769a75a85c9057d0fc7667e0d72e75ed38ba5c866
#11 name: "[compilation 4/8] COPY . /go/src/github.com/"
#11 started: 2018-11-30 06:56:57.154522146 +0000 UTC m=+213.053313865
#11 0.129 container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"overlay\\\" to rootfs \\\"/tmp/build/2ebbeb81/cache/runc/overlayfs/executor/qg593ckedekv12831f4nevs99/rootfs\\\" at \\\"/tmp/build/2ebbeb81/cache/runc/overlayfs/executor/qg593ckedekv12831f4nevs99/rootfs/dest\\\" caused \\\"no such file or directory\\\"\""
#11 completed: 2018-11-30 06:56:57.465694351 +0000 UTC m=+213.364486108
#11 duration: 311.172243ms
#11 error: "executor failed running [copy /src-0 go/src/github.com/]: exit code: 1"
error reproduce:
runtime && setup:
○ → uname -a
Linux huan-Inspiron-5379 4.18.0-11-generic #12-Ubuntu SMP Tue Oct 23 19:22:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
○ → docker --version
Docker version 18.06.1-ce, build e68fc7a
○ → docker run --entrypoint sh --user root --rm -it --privileged r.j3ss.co/img
/ # mkdir -p /tmp/temp && cd /tmp/temp
/tmp/temp # mkdir cache context dockerfile
/tmp/temp # cat <<'EOF' > dockerfile/Dockerfile
> FROM ubuntu
> COPY . /tmp
> EOF
/tmp/temp # tree # installed using `apk add tree`
.
├── cache
├── context
└── dockerfile
└── Dockerfile
testing:
/tmp/temp # img build -f dockerfile/Dockerfile -t test context/
Building docker.io/library/test:latest
Setting up the rootfs... this may take a bit.
[+] Building 1.9s (8/8) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 61B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:latest 0.8s
=> CACHED [internal] helper image for file operations 0.0s
=> => resolve docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [1/2] FROM docker.io/library/ubuntu@sha256:6d0e0c26489e33f5a6f002 0.0s
=> => resolve docker.io/library/ubuntu@sha256:6d0e0c26489e33f5a6f0020edface 0.0s
=> [2/2] COPY . /tmp 0.6s
=> exporting to image 0.5s
=> => exporting layers 0.4s
=> => exporting manifest sha256:c2575f4e9a615f4f58b78e77918a449cdf6b85ec0eb 0.0s
=> => exporting config sha256:ec88ee2b1ee574f7ad6faf11d86619a36d05939771ae9 0.0s
=> => naming to docker.io/library/test:latest 0.0s
Successfully built docker.io/library/test:latest
/tmp/temp # img build -s cache -f dockerfile/Dockerfile -t test context/
Building docker.io/library/test:latest
Setting up the rootfs... this may take a bit.
[+] Building 1.3s (7/7) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 31B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:latest 0.7s
=> [internal] load build context 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [1/2] FROM docker.io/library/ubuntu@sha256:6d0e0c26489e33f5a6f002 0.0s
=> => resolve docker.io/library/ubuntu@sha256:6d0e0c26489e33f5a6f0020edface 0.0s
=> CACHED [internal] helper image for file operations 0.0s
=> => resolve docker.io/tonistiigi/copy:v0.1.9@sha256:e8f159d3f00786604b93c 0.0s
=> ERROR [2/2] COPY . /tmp 0.5s
------
> [2/2] COPY . /tmp:
#7 0.440 container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/tmp/temp/cache/runc/native/executor/0ce4hpp715qbvwg8gj8y5vwxa/cache/runc/native/snapshots/snapshots/13\\\" to rootfs \\\"/tmp/temp/cache/runc/native/executor/0ce4hpp715qbvwg8gj8y5vwxa/rootfs\\\" at \\\"/dest\\\" caused \\\"stat /tmp/temp/cache/runc/native/executor/0ce4hpp715qbvwg8gj8y5vwxa/cache/runc/native/snapshots/snapshots/13: no such file or directory\\\"\""
------
failed to solve: executor failed running [copy /src-0 tmp]: exit code: 1
What's the filesystem of the directory?
Either changing the directory or specifying native snapshotter should work.
both are btrfs. I don't think its file system's problem. Because if I symlink the cache directory to /home/user/.local/share/img, then I can run img build -f dockerfile/Dockerfile -t test context/ just fine. And all the contents are successfully cached in the cache directory
I've had a very similar issue that in the end was due to hitting the page size limitation on mount arguments. On overlay mounts as carried out by img / runc, the "lower" argument in the mount data grows with every layer added. When the mount data hits 8192 bytes in my case, the build process failed with the confusing error above. In my case I could not build Dockerfiles with more than around 80 layers. I extended the number of layers that could be build properly by using a very short path to state and specified that using the "-s" parameter.
Docker at one time ran into the same issue apparently:
- https://github.com/portworx/docker_docs/blob/master/docs/userguide/storagedriver/overlayfs-driver.md
Further discussion:
- https://github.com/moby/moby/issues/26380