Hi!
Compare these 2 jobs:
Notice the difference:
Step 1/3 : FROM hello-world:linux
linux: Pulling from library/hello-world
0e03bdcc26d7: Pulling fs layer
0e03bdcc26d7: Verifying Checksum
0e03bdcc26d7: Download complete
0e03bdcc26d7: Pull complete
Digest: sha256:d073a5775c0b99d653c413161a8ed0e9685061afe697931d30eddf6afeef40f6
Status: Downloaded newer image for hello-world:linux
---> bf756fb1ae65
Step 2/3 : ENV hello=world
---> Running in db0fc4355854
Removing intermediate container db0fc4355854
---> 0430147d2bd7
Step 3/3 : ENV world=hello
---> Running in b742be361e05
Removing intermediate container b742be361e05
---> 823a4ea0983b
Successfully built 823a4ea0983b
vs my own code which actually uses cache
Step 1/3 : FROM hello-world:linux
linux: Pulling from library/hello-world
0e03bdcc26d7: Already exists
Digest: sha256:d073a5775c0b99d653c413161a8ed0e9685061afe697931d30eddf6afeef40f6
Status: Downloaded newer image for hello-world:linux
---> bf756fb1ae65
Step 2/3 : ENV hello=world
---> Using cache
---> 5ea1c2e029fd
Step 3/3 : ENV world=hello
---> Using cache
---> 7225a4358ba0
Successfully built 7225a4358ba0
Successfully tagged image:latest
Pulling image before using --cache-from does the trick:
docker pull lexinek/hello-world || true
docker build . --tag image --cache-from lexinek/hello-world
Because the --cache-from has no effect if the image does not exist and since it runs in CI environment, the image is not pulled there 😉
Hi!
Compare these 2 jobs:
Notice the difference:
vs my own code which actually uses cache
Pulling image before using
--cache-fromdoes the trick:Because the
--cache-fromhas no effect if the image does not exist and since it runs in CI environment, the image is not pulled there 😉