Skip to content

COPY still invalidates cache when no files have changed. #21913

@kojiromike

Description

@kojiromike

BUG REPORT INFORMATION

Output of docker version:

Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.6
 Git commit:   20f81dd
 Built:        Sat Mar 12 04:07:44 UTC 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 21:49:11 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 11
 Running: 8
 Paused: 0
 Stopped: 3
Images: 94
Server Version: 1.10.3
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 149
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins: 
 Volume: local
 Network: bridge null host
Kernel Version: 4.1.19-boot2docker
Operating System: Boot2Docker 1.10.3 (TCL 6.4.1); master : 625117e - Thu Mar 10 22:09:02 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.859 GiB
Name: boot2docker
ID: C3GY:3N5K:CDC5:KKPV:KGRB:EMTU:5L5X:VWJC:LBZE:NARH:DC4Y:KGDO
Debug mode (server): true
 File Descriptors: 80
 Goroutines: 107
 System Time: 2016-04-10T00:56:25.678982655Z
 EventsListeners: 0
 Init SHA1: 
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
 provider=xhyve

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

Running with xhyve on a Mac

Steps to reproduce the issue:

  1. Put a Dockerfile with a large number of build steps following a COPY . /path in a repo working dir.
  2. docker build .
  3. Change only the Dockerfile
  4. docker build . again.
  5. Add Dockerfile to .dockerignore.
  6. Repeat steps 3 and 4.

Describe the results you received:

In both steps 4 and 6 the build cache was invalidated after the COPY step.

Describe the results you expected:

The build cache should ignore changes to files in .dockerignore. The Dockerfile itself should never invalidate the build cache. If this is expected behavior, then searching for "Dockerfile COPY invalidates cache" should give me more clues than it does. (As in, I should be able to find documentation describing why the cache is being busted.)

Additional information you deem important (e.g. issue happens only occasionally):
Frankly, given #10336 and its related issues, all closed, I can only assume that this is something I don't understand. If that's the case, I would really appreciate seeing it documented so I understand what I can do in my Dockerfile to prevent changing only the Dockerfile from invalidating the COPY cache.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions