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

Blanking a parent image's ENTRYPOINT busts the child's cache #37643

Open
shargan opened this issue Aug 15, 2018 · 5 comments
Open

Blanking a parent image's ENTRYPOINT busts the child's cache #37643

shargan opened this issue Aug 15, 2018 · 5 comments

Comments

@shargan
Copy link

shargan commented Aug 15, 2018

Description
If a parent docker image defines ENTRYPOINT and a child blanks it out (ENTRYPOINT []), that line in the child busts the cache.

Steps to reproduce the issue:
Create three Dockerfiles:

bugreport$ cat Dockerfile.parent
FROM ubuntu:16.04

ENTRYPOINT ["/bin/bash"]
bugreport$ cat Dockerfile.child.empty
FROM parent

RUN echo "This remains cached"
ENTRYPOINT []
RUN echo "This does not get cached"
bugreport$ cat Dockerfile.child.redefined
FROM parent

RUN echo "This remains cached"
ENTRYPOINT ["/bin/ls"]
RUN echo "So does this"

Now build the parent:

bugreport$ docker build -t parent -f Dockerfile.parent .
Sending build context to Docker daemon  4.096kB
Step 1/2 : FROM ubuntu:16.04
 ---> 7aa3602ab41e
Step 2/2 : ENTRYPOINT ["/bin/bash"]
 ---> Running in ccb2deaac166
Removing intermediate container ccb2deaac166
 ---> a16fa2461ffc
Successfully built a16fa2461ffc
Successfully tagged parent:latest

Describe the results you expected:
Repeatedly building child.redefined behaves exactly as expected. Each stage is cached and the final result is identical each timel: 00427e0e1d2e.

bugreport$ docker build -t child.redefined -f Dockerfile.child.redefined .
Sending build context to Docker daemon  4.096kB
Step 1/4 : FROM parent
 ---> a16fa2461ffc
Step 2/4 : RUN echo "This remains cached"
 ---> Running in 986158df8103
This remains cached
Removing intermediate container 986158df8103
 ---> 3f75db9409f7
Step 3/4 : ENTRYPOINT ["/bin/ls"]
 ---> Running in defe95cbcbd6
Removing intermediate container defe95cbcbd6
 ---> 5500f9c8717e
Step 4/4 : RUN echo "So does this"
 ---> Running in 9c8f27fa210d
So does this
Removing intermediate container 9c8f27fa210d
 ---> 00427e0e1d2e
Successfully built 00427e0e1d2e
Successfully tagged child.redefined:latest

bugreport$ docker build -t child.redefined -f Dockerfile.child.redefined .
Sending build context to Docker daemon  4.096kB
Step 1/4 : FROM parent
 ---> a16fa2461ffc
Step 2/4 : RUN echo "This remains cached"
 ---> Using cache
 ---> 3f75db9409f7
Step 3/4 : ENTRYPOINT ["/bin/ls"]
 ---> Using cache
 ---> 5500f9c8717e
Step 4/4 : RUN echo "So does this"
 ---> Using cache
 ---> 00427e0e1d2e
Successfully built 00427e0e1d2e
Successfully tagged child.redefined:latest

Describe the results you received:
Repeatedly building child.empty shows that the cache busts at the ENTRYPOINT line. As a result, a new image is produced and tagged on every single build.

bugreport$ docker build -t child.empty -f Dockerfile.child.empty .
Sending build context to Docker daemon  4.096kB
Step 1/4 : FROM parent
 ---> a16fa2461ffc
Step 2/4 : RUN echo "This remains cached"
 ---> Using cache
 ---> 3f75db9409f7
Step 3/4 : ENTRYPOINT []
 ---> Running in 0ad4aefa6893
Removing intermediate container 0ad4aefa6893
 ---> 19d67ed46785
Step 4/4 : RUN echo "This does not get cached"
 ---> Running in 7db2a04106e4
This does not get cached
Removing intermediate container 7db2a04106e4
 ---> ccdea9f05e9d
Successfully built ccdea9f05e9d
Successfully tagged child.empty:latest

bugreport$ docker build -t child.empty -f Dockerfile.child.empty .
Sending build context to Docker daemon  4.096kB
Step 1/4 : FROM parent
 ---> a16fa2461ffc
Step 2/4 : RUN echo "This remains cached"
 ---> Using cache
 ---> 3f75db9409f7
Step 3/4 : ENTRYPOINT []
 ---> Running in 001c6f25cf8b
Removing intermediate container 001c6f25cf8b
 ---> 41312197b9d4
Step 4/4 : RUN echo "This does not get cached"
 ---> Running in 468b23e378c7
This does not get cached
Removing intermediate container 468b23e378c7
 ---> 2515835107b0
Successfully built 2515835107b0
Successfully tagged child.empty:latest

Since the dockerfile has not changed, each stage should be cached and an identical image produced/tagged at the end.

Output of docker version:

bugreport$ docker version
Client:
 Version:           18.06.0-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        0ffa825
 Built:             Wed Jul 18 19:05:26 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.0-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       0ffa825
  Built:            Wed Jul 18 19:13:46 2018
  OS/Arch:          linux/amd64
  Experimental:     true

Output of docker info:

bugreport$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 119
Server Version: 18.06.0-ce
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: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.93-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: ZPNR:CRR5:7M66:5RIA:U6BT:CRKN:EIVT:O7TZ:5X2E:P447:UFT6:KBXZ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 26
 Goroutines: 53
 System Time: 2018-08-15T01:18:23.5042913Z
 EventsListeners: 2
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

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

This is on a Macbook Pro running High Sierra 10.13.6.

I cannot reproduce the issue on an Ubuntu 16.04 host running 17.05.0-ce server and client.

@thomasbiddle
Copy link

I've run into this as well; I believe it was only when mine was set to [""] - [" "] and [] worked - but I'd have to reverify.

@Hafas
Copy link

Hafas commented Sep 10, 2019

This is on a Macbook Pro running High Sierra 10.13.6.
I cannot reproduce the issue on an Ubuntu 16.04 host running 17.05.0-ce server and client.

I can reproduce the issue on Ubuntu 18.04.3 and Docker 19.03.2

Simple Dockerfile:

FROM ubuntu

RUN echo "this gets cached"

ENTRYPOINT ["true"]

RUN echo "this gets cached too"

ENTRYPOINT []

RUN echo "this one doesn't get cached"

Output on first build:

Sending build context to Docker daemon  2.048kB
Step 1/6 : FROM ubuntu
 ---> a2a15febcdf3
Step 2/6 : RUN echo "this gets cached"
 ---> Running in ab0cc610bd9f
this gets cached
Removing intermediate container ab0cc610bd9f
 ---> 8022cc94e411
Step 3/6 : ENTRYPOINT ["true"]
 ---> Running in d8c3212d131e
Removing intermediate container d8c3212d131e
 ---> b8178335171a
Step 4/6 : RUN echo "this gets cached too"
 ---> Running in 79725d93d5c2
this gets cached too
Removing intermediate container 79725d93d5c2
 ---> 91cd779e3b13
Step 5/6 : ENTRYPOINT []
 ---> Running in f236288f83ec
Removing intermediate container f236288f83ec
 ---> 235b1973a8f3
Step 6/6 : RUN echo "this one doesn't get cached"
 ---> Running in e9477f805d8d
this one doesn't get cached
Removing intermediate container e9477f805d8d
 ---> 93909525e605
Successfully built 93909525e605

Output on 2nd and further builds:

Sending build context to Docker daemon  2.048kB
Step 1/6 : FROM ubuntu
 ---> a2a15febcdf3
Step 2/6 : RUN echo "this gets cached"
 ---> Using cache
 ---> 8022cc94e411
Step 3/6 : ENTRYPOINT ["true"]
 ---> Using cache
 ---> b8178335171a
Step 4/6 : RUN echo "this gets cached too"
 ---> Using cache
 ---> 91cd779e3b13
Step 5/6 : ENTRYPOINT []
 ---> Running in 01920ae6d559
Removing intermediate container 01920ae6d559
 ---> 5629755d105b
Step 6/6 : RUN echo "this one doesn't get cached"
 ---> Running in 1ec17e10beab
this one doesn't get cached
Removing intermediate container 1ec17e10beab
 ---> 0de98c21d7f9
Successfully built 0de98c21d7f9

Step 5 & 6 doesn't get cached

@tianon
Copy link
Member

tianon commented Nov 4, 2020

This was rediscovered/reconfirmed in #3465 (comment). 😞

@tianon
Copy link
Member

tianon commented Nov 4, 2020

$ docker version
Client: Docker Engine - Community
 Version:           20.10.0-beta1
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        ac365d7
 Built:             Tue Oct 13 18:13:41 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.0-beta1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       9c15e82
  Built:            Tue Oct 13 18:17:18 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.1
  GitCommit:        c623d1b36f09f8ef6536a057bd658b3aa8632828
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ cat Dockerfile
FROM bash
ENTRYPOINT []
RUN echo never cached

$ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM bash
latest: Pulling from library/bash
188c0c94c7c5: Pull complete 
94387ca39817: Pull complete 
efe7174943e6: Pull complete 
Digest: sha256:01fad26fa8ba21bce6e8c47222acfdb54649957f1e86d53a0c8e03360271abf6
Status: Downloaded newer image for bash:latest
 ---> 39a95ac32011
Step 2/3 : ENTRYPOINT []
 ---> Running in 849b813584b7
Removing intermediate container 849b813584b7
 ---> 83780b57402b
Step 3/3 : RUN echo never cached
 ---> Running in f67165121267
never cached
Removing intermediate container f67165121267
 ---> 129d3f56aaad
Successfully built 129d3f56aaad

$ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM bash
 ---> 39a95ac32011
Step 2/3 : ENTRYPOINT []
 ---> Running in 893405f7299b
Removing intermediate container 893405f7299b
 ---> 5e34458be803
Step 3/3 : RUN echo never cached
 ---> Running in 026c08b3f84e
never cached
Removing intermediate container 026c08b3f84e
 ---> ceb1d3fed119
Successfully built ceb1d3fed119

@thaJeztah
Copy link
Member

Yes, was able to reproduce; looks to be only with the classic builder, and not with buildkit;

mkdir repro-37643 && cd repro-37643

cat > Dockerfile -<<'EOF'
FROM bash
ENTRYPOINT []
RUN echo never cached
EOF
DOCKER_BUILDKIT=0 docker build .

Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM bash
latest: Pulling from library/bash
188c0c94c7c5: Already exists
94387ca39817: Pull complete
efe7174943e6: Pull complete
Digest: sha256:01fad26fa8ba21bce6e8c47222acfdb54649957f1e86d53a0c8e03360271abf6
Status: Downloaded newer image for bash:latest
 ---> 39a95ac32011
Step 2/3 : ENTRYPOINT []
 ---> Running in 0bfdba8a93a9
Removing intermediate container 0bfdba8a93a9
 ---> 949b6885127b
Step 3/3 : RUN echo never cached
 ---> Running in b4cff1140a3c
never cached
Removing intermediate container b4cff1140a3c
 ---> 05b7507d3eda
Successfully built 05b7507d3eda
DOCKER_BUILDKIT=0 docker build .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM bash
 ---> 39a95ac32011
Step 2/3 : ENTRYPOINT []
 ---> Running in 3f78aa541994
Removing intermediate container 3f78aa541994
 ---> 0b195faa28c7
Step 3/3 : RUN echo never cached
 ---> Running in 0d5ddecf31ee
never cached
Removing intermediate container 0d5ddecf31ee
 ---> 882bf67681da
Successfully built 882bf67681da
bash-5.0$ DOCKER_BUILDKIT=1 docker build .
[+] Building 1.1s (6/6) FINISHED
 => [internal] load .dockerignore                                                                0.2s
 => => transferring context: 2B                                                                  0.0s
 => [internal] load build definition from Dockerfile                                             0.1s
 => => transferring dockerfile: 88B                                                              0.0s
 => [internal] load metadata for docker.io/library/bash:latest                                   0.0s
 => [1/2] FROM docker.io/library/bash                                                            0.3s
 => => resolve docker.io/library/bash:latest                                                     0.0s
 => [2/2] RUN echo never cached                                                                  0.4s
 => exporting to image                                                                           0.1s
 => => exporting layers                                                                          0.1s
 => => writing image sha256:a1bb8d52d475aec5a3cc09b2ece0b40a881dac44512fa6b5530c05fe462359c6     0.0s
bash-5.0$ DOCKER_BUILDKIT=1 docker build .
[+] Building 0.2s (6/6) FINISHED
 => [internal] load .dockerignore                                                                0.1s
 => => transferring context: 2B                                                                  0.0s
 => [internal] load build definition from Dockerfile                                             0.2s
 => => transferring dockerfile: 36B                                                              0.0s
 => [internal] load metadata for docker.io/library/bash:latest                                   0.0s
 => [1/2] FROM docker.io/library/bash                                                            0.0s
 => CACHED [2/2] RUN echo never cached                                                           0.0s
 => exporting to image                                                                           0.0s
 => => exporting layers                                                                          0.0s
 => => writing image sha256:a1bb8d52d475aec5a3cc09b2ece0b40a881dac44512fa6b5530c05fe462359c6     0.0s

btalb added a commit to qcr/benchbot that referenced this issue Feb 13, 2022
btalb added a commit to qcr/benchbot that referenced this issue Feb 14, 2022
btalb added a commit to qcr/benchbot that referenced this issue Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants