Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue COPY a file to a symlink directory #958

Closed
leonlau opened this issue Apr 24, 2019 · 6 comments
Closed

Issue COPY a file to a symlink directory #958

leonlau opened this issue Apr 24, 2019 · 6 comments

Comments

@leonlau
Copy link

leonlau commented Apr 24, 2019

An error occurred when I used buildkit COPY a file to a symlink directory

Dockerfile :

...
ADD  php-fpm.conf  /usr/local/php/etc/
...

base image directory

$ ls -l /usr/local
lrwxrwxrwx 1 root root      21 Apr 24 14:57 php -> /usr/local/php-5.4.26
drwxr-xr-x 9 root root      81 Aug 28  2018 php-5.4.26

error output :

 => ERROR [5/14] ADD  php-fpm.conf  /usr/local/php/etc/                                                                    0.6s
------
 > [5/14] ADD  php-fpm.conf  /usr/local/php/etc/:
#10 0.317 panic: mkdir usr/local/php: file exists
#10 0.317
#10 0.317 goroutine 1 [running]:
#10 0.317 main.main()
#10 0.317 	/go/src/github.com/tonistiigi/copy/cmd/copy/main.go:57 +0x2af
------
executor failed running [copy --unpack /src-0/php-fpm.conf usr/local/php/etc/]: exit code: 2

docker version :
Client:
Version: 18.09.5
API version: 1.39
Go version: go1.10.8
Git commit: e8ff056
Built: Thu Apr 11 04:43:34 2019
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.5
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: e8ff056
Built: Thu Apr 11 04:13:40 2019
OS/Arch: linux/amd64
Experimental: true

@leonlau
Copy link
Author

leonlau commented Apr 24, 2019

Found the same problem:
github.com/moby/buildkit v0.4.0
and
github.com/moby/buildkit v0.4.1-0.20190417144954-02b477d8a32a

@tonistiigi
Copy link
Member

This issue should be gone in v0.5.0 and 19.03 with the new fileop implementation. If using #syntax Dockerfile version needs to be 1.1.0+

@CpuID
Copy link
Contributor

CpuID commented May 3, 2019

Confirmed, same issue here. Easy to repro:

$ cat Dockerfile.test 
FROM alpine:3.9

RUN rm -f /var/spool/cron/crontabs/root
COPY ./crontab /var/spool/cron/crontabs/root
$ docker build -f Dockerfile.test .
[+] Building 1.0s (8/8) FINISHED                                                                                                                                          
 => [internal] load build definition from Dockerfile.test                                                                                                            0.0s
 => => transferring dockerfile: 150B                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/alpine:3.9                                                                                                        0.0s
 => CACHED [1/3] FROM docker.io/library/alpine:3.9                                                                                                                   0.0s
 => CACHED [internal] helper image for file operations                                                                                                               0.0s
 => [internal] load build context                                                                                                                                    0.1s
 => => transferring context: 29B                                                                                                                                     0.0s
 => [2/3] RUN rm -f /var/spool/cron/crontabs/root                                                                                                                    0.5s
 => ERROR [3/3] COPY ./crontab /var/spool/cron/crontabs/root                                                                                                         0.5s
------
 > [3/3] COPY ./crontab /var/spool/cron/crontabs/root:
#8 0.287 panic: mkdir var/spool/cron/crontabs: file exists
#8 0.287 
#8 0.287 goroutine 1 [running]:
#8 0.287 main.main()
#8 0.287 	/go/src/github.com/tonistiigi/copy/cmd/copy/main.go:57 +0x2af
------
executor failed running [copy /src-0/crontab var/spool/cron/crontabs/root]: exit code: 2

Versions:

$ docker version
Client:
 Version:           18.09.5
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        e8ff056
 Built:             Thu Apr 11 04:43:57 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.5
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       e8ff056
  Built:            Thu Apr 11 04:10:53 2019
  OS/Arch:          linux/amd64
  Experimental:     false

$ buildkitd --version
buildkitd github.com/moby/buildkit 0.0.0 49906c62925ed429ec9174a0b6869982967f1a39

@CpuID
Copy link
Contributor

CpuID commented May 3, 2019

This issue should be gone in v0.5.0 and 19.03 with the new fileop implementation. If using #syntax Dockerfile version needs to be 1.1.0+

Is 19.03 an official/stable release? Can't see it on https://docs.docker.com/engine/release-notes/

@CpuID
Copy link
Contributor

CpuID commented May 3, 2019

ah, 19.03 = still beta

https://github.com/docker/docker-ce/releases

@CpuID
Copy link
Contributor

CpuID commented May 3, 2019

Confirmed, works fine using Ubuntu test builds (standard Docker apt repo)

Server:
 Engine:
  Version:          19.03.0-beta3
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.4
  Git commit:       c55e026
  Built:            Thu Apr 25 02:57:32 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.5
  GitCommit:        bb71b10fd8f58240ca47fbb579b9d1028eea7c84
 runc:
  Version:          1.0.0-rc6+dev
  GitCommit:        2b18fe1d885ee5083ef9f0838fee39b62d653e30
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
$ docker build -f Dockerfile.test  .
[+] Building 0.3s (8/8) FINISHED                                                                                                                                          
 => [internal] load .dockerignore                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                      0.0s
 => [internal] load build definition from Dockerfile.test                                                                                                            0.0s
 => => transferring dockerfile: 150B                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/alpine:3.9                                                                                                        0.0s
 => [1/3] FROM docker.io/library/alpine:3.9                                                                                                                          0.0s
 => [internal] load build context                                                                                                                                    0.0s
 => => transferring context: 29B                                                                                                                                     0.0s
 => CACHED [2/3] RUN rm -f /var/spool/cron/crontabs/root                                                                                                             0.0s
 => [3/3] COPY ./crontab /var/spool/cron/crontabs/root                                                                                                               0.1s
 => exporting to image                                                                                                                                               0.1s
 => => exporting layers                                                                                                                                              0.1s
 => => writing image sha256:66478342866c17bcbed9477b087b0f5e9228513b969494a64f11d80599b1cb5a                                                                         0.0s

@leonlau leonlau closed this as completed May 6, 2019
thaJeztah added a commit to thaJeztah/docker that referenced this issue Oct 24, 2019
full diff: moby/buildkit@f704282...ae10b29

fixes:

- moby/buildkit#1144 Fix socket handling
    - fsutil: Handle copying unix sockets in local sources
    - update github.com/containerd/continuity to 75bee3e2ccb6
    - update github.com/tonistiigi/fsutil to 3d2716dd0a4d
- moby/buildkit#1150 ssh: Fix file descriptor leak when doing SSH forwarding
    - fixes moby/buildkit#1146 SSH Forwarding Doesn't Release File Descriptors
- moby/buildkit#1156 llbsolver: Fix using multiple remote cache importers
- moby/buildkit#1159 http: Handle missing but unambiguous ETags in response
    - fixes moby/buildkit#905 ADD from url fails with 'invalid not-modified ETag'
    - fixes moby/buildkit#784 invalid not-modified ETag with local network ADD in docker
- moby/buildkit#1166 solver: Fix possible inefficient parallelization in solver
    - fix cases where some events were dropped resulting inefficient parallelization.
- moby/buildkit#1168 vendor: update go-runc to e029b79d
- moby/buildkit#1140 contenthash: Fix bug with symlink in source path of a copy operation
    - fixes moby/buildkit#974 COPY --from fails when source path involves a symlink
    - fixes moby/buildkit#785 COPY rpc error: code = Unknown desc = not found: not found
    - fixes moby/buildkit#958 Issue COPY a file to a symlink directory
- moby/buildkit#1139 executor: oom_score_adj is no longer set from main process

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants