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

--cache-from invalidates caches for ADD command #36771

Open
zen0wu opened this issue Apr 3, 2018 · 1 comment
Open

--cache-from invalidates caches for ADD command #36771

zen0wu opened this issue Apr 3, 2018 · 1 comment

Comments

@zen0wu
Copy link

zen0wu commented Apr 3, 2018

Description

Steps to reproduce the issue:

  1. Use the following simple Dockerfile
FROM python:3.6.5

RUN echo "START"
RUN mkdir /test
ADD a /test
RUN echo "AHA"
  1. Run docker build --cache-from shivawu/test-cache-from .
  2. Run 2 again

Describe the results you received:

[ec2-user@ip-192-0-0-151 test]$ docker build --pull -t shivawu/test-cache-from:test6 --cache-from shivawu/test-cache-from:test5 .
Sending build context to Docker daemon  2.56 kB
Step 1/6 : FROM python:3.6.5
3.6.5: Pulling from library/python
Digest: sha256:ed978c29213ab3360766d2f42a898d5faa60e27294f142ba58c6c3617896a52b
Status: Image is up to date for python:3.6.5
 ---> efb6baa1169f
Step 2/6 : RUN apt-get update && apt-get install -y vim
 ---> Using cache
 ---> ea40cb37d9bf
Step 3/6 : RUN echo "START"
 ---> Using cache
 ---> 5f18a85fd606
Step 4/6 : RUN mkdir /test
 ---> Using cache
 ---> 1451f6ff4b55
Step 5/6 : ADD a /test
 ---> 5ca8fec6c97f
Removing intermediate container 8bd9a93a1edf
Step 6/6 : RUN echo "AHA"
 ---> Running in cd6a87a7c1c8
AHA
 ---> cd286d325aca
Removing intermediate container cd6a87a7c1c8
Successfully built cd286d325aca
[ec2-user@ip-192-0-0-151 test]$ docker build --pull -t shivawu/test-cache-from:test6 --cache-from shivawu/test-cache-from:test5 .
Sending build context to Docker daemon  2.56 kB
Step 1/6 : FROM python:3.6.5
3.6.5: Pulling from library/python
Digest: sha256:ed978c29213ab3360766d2f42a898d5faa60e27294f142ba58c6c3617896a52b
Status: Image is up to date for python:3.6.5
 ---> efb6baa1169f
Step 2/6 : RUN apt-get update && apt-get install -y vim
 ---> Using cache
 ---> ea40cb37d9bf
Step 3/6 : RUN echo "START"
 ---> Using cache
 ---> 5f18a85fd606
Step 4/6 : RUN mkdir /test
 ---> Using cache
 ---> 1451f6ff4b55
Step 5/6 : ADD a /test
 ---> 85441a2840a8
Removing intermediate container 3805300332bc
Step 6/6 : RUN echo "AHA"
 ---> Running in e0c8bbfed714
AHA
 ---> 6e496426a963
Removing intermediate container e0c8bbfed714
Successfully built 6e496426a963

Describe the results you expected:

As you can see, the two run of docker build diverge from step 5, all steps from 1-4 are using the cache, but when encountered an ADD instruction, it fails to use the cache.

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

Output of docker version:

Client:
 Version:	18.03.0-ce
 API version:	1.37
 Go version:	go1.9.4
 Git commit:	0520e24
 Built:	Wed Mar 21 23:06:22 2018
 OS/Arch:	darwin/amd64
 Experimental:	false
 Orchestrator:	swarm

Server:
 Engine:
  Version:	18.03.0-ce
  API version:	1.37 (minimum version 1.12)
  Go version:	go1.9.4
  Git commit:	0520e24
  Built:	Wed Mar 21 23:14:32 2018
  OS/Arch:	linux/amd64
  Experimental:	true

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 44
Server Version: 18.03.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: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: Z2LA:YT54:G4DX:G4LY:JAH2:5DVY:ZCUZ:F2GA:DXNX:BE6Z:IICC:ZC5X
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 22
 Goroutines: 40
 System Time: 2018-04-03T05:26:33.970715485Z
 EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.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.):

@zen0wu zen0wu changed the title --cache-from invalidates caches for any ADD/RUN command --cache-from invalidates caches for ADD command Apr 3, 2018
@arm64b
Copy link
Contributor

arm64b commented Apr 4, 2018

I can't reproduce in my system, or your produce steps list above is not exactly match your actual operation.
First you need to tag the image you're building like this:
docker build -t shivawu/test-cache-from ., then you can test if the cache is OK with:
docker build --cache-from shivawu/test-cache-from -t shivawu/test-cache-from:test0 .

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

3 participants