dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

Cache miss with cache-from on COPY command #198

Open volfyd opened 4 years ago

volfyd commented 4 years ago

Hi,

I wanted to start using the cache-from feature, but I noticed that no matter what I was doing, COPY commands in my Dockerfile were always missing the cache. I eventually realized that it has to do with the version of the docker client that built the image I'm using in cache-from.

image=foo:
    image: foo
    cache-from: [ 'bar:current' ]
    context: foo
    tags: [ 'current' ]

If I run:

docker -t bar:current foo
dobi foo

I get a cache miss on COPY instructions. If I downgrade the docker client to

Client:
 Version:      17.09.1-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:21:47 2017
 OS/Arch:      linux/amd64

and start over, caching starts working correctly. I tried 17.12.0 and up, and those all have the problem.

Would this require the go-dockerclient library to support a higher client version? I don't know if something changed with the way hashes are computed.

dnephin commented 3 years ago

I'm not sure, but you can set the API version that the client sends to the server with the DOCKER_API_VERSION environment variable. go-dockerclient supports the same variable. Maybe that will work?