I want to reuse the layers from a docker image on two different machines in the following way:
- Build image (1)
- Push image to registry (1)
- Pull image from registry (2)
- Build same docker image and reuse layers from pulled image (2)
Therefore,
Machine 1:
I build this following image:
FROM node:13-slim
COPY package.json package.json
- Build this image with the following command:
docker build . -t <registry>/test-docker-image:latest
- Push the image to a registry:
docker push <registry>/test-docker-image:latest
Machine 2
- Pull the image from the registry:
docker pull <registry>/test-docker-image:latest
If I run docker build .
on this machine the layers are not reused from the pulled image.
Is there a way to reuse the layers from the pulled image in the docker build
?
Similar issue:
There is the following thread on GitHub that describes something similar, but this describes the issue between sharing layers between docker build
and docker-compose build
. https://github.com/docker/compose/issues/883