Skip to content

symlinks not part of build context hash #34260

@justincormack

Description

@justincormack

create the following Dockerfile:

FROM alpine AS alpine

RUN touch a
RUN ln -s a /tmp/b
RUN ln -s a /tmp/c

FROM scratch
COPY --from=alpine /bin /bin
COPY --from=alpine /lib /lib
COPY --from=alpine /usr /usr
COPY --from=alpine /tmp /tmp

RUN ls /tmp

build with docker build .
then comment out one ln:

FROM alpine AS alpine

RUN touch a
RUN ln -s a /tmp/b
#RUN ln -s a /tmp/c

FROM scratch
COPY --from=alpine /bin /bin
COPY --from=alpine /lib /lib
COPY --from=alpine /usr /usr
COPY --from=alpine /tmp /tmp

RUN ls /tmp

build again and notice the output is:

Step 1/9 : FROM alpine AS alpine
 ---> 665ffb03bfae
Step 2/9 : RUN touch a
 ---> Using cache
 ---> 0801a30708b5
Step 3/9 : RUN ln -s a /tmp/b
 ---> Using cache
 ---> 1fa1bebaae04
Step 4/9 : FROM scratch
 ---> 
Step 5/9 : COPY --from=alpine /bin /bin
 ---> Using cache
 ---> 524b53bbe62a
Step 6/9 : COPY --from=alpine /lib /lib
 ---> Using cache
 ---> a2f12072d943
Step 7/9 : COPY --from=alpine /usr /usr
 ---> Using cache
 ---> 5d09b665f011
Step 8/9 : COPY --from=alpine /tmp /tmp
 ---> Using cache
 ---> aa9cb5d399d5
Step 9/9 : RUN ls /tmp
 ---> Using cache
 ---> dcbc13560636
Successfully built dcbc13560636

ie it all came from cache, and indeed both symlinks are in the output, when only one is correct (eg if built with no-cache)

Client:
 Version:      17.06.1-ce-rc1
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   77b4dce
 Built:        Fri Jul 14 07:38:15 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.06.1-ce-rc1
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   77b4dce
 Built:        Fri Jul 14 07:33:35 2017
 OS/Arch:      linux/amd64
 Experimental: true
Containers: 155
 Running: 0
 Paused: 0
 Stopped: 155
Images: 989
Server Version: 17.06.1-ce-rc1
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.38-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: moby
ID: 62QR:HC6P:CL3A:X2OU:VT2R:D4OH:K7PC:W2TG:X6JP:OFZE:PJKA:F2D3
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 18
 Goroutines: 30
 System Time: 2017-07-26T14:25:31.789026387Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

cc @tonistiigi

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/builderBuildkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.version/17.06

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions