Reputation: 3626
I was pushing some images to a cloud cluster when I noticed some interesting output:
$ docker push serviceD
37794ab1f6ab: Mounted from serviceA
a481fcabd5ce: Pushed
6386b9576417: Pushed
7b130cab9651: Pushed
21981e3c578d: Pushed
9d19b6b6a1f0: Mounted from serviceB
3e590131f755: Mounted from serviceB
fd77fd1b66f8: Mounted from serviceB
522caa449807: Mounted from serviceB
8dfad2055603: Mounted from serviceA
This made me wonder, what does it mean when the output says Mounted from serviceX
? These are services I already pushed, by the way. I initially thought that perhaps because some services, like serviceD, talk to other services, that things are shared. But since I am building a single microservice, other microservices don't come into the equation when I'm building this container.
So... I guess my questions are what are the specific steps of a build? Where do these docker (hashes, I'm assuming) come from, and why might several hashes be the same? To be honest, I am not really sure what any of this output means. What do these hashes represent?
Upvotes: 2
Views: 70
Reputation: 484
To understand the build process, you have to be familiar with Docker image layers. Every image is a number of layers built on top of each other. Let's say our docker image is being built from a Dockerfile, where we have a set of commands being executed as the image is being built. Some of those commands in Dockerfile (like ADD, RUN etc.) create the so called layer. The resulting image in the end is all of it's layers combined together. If you're building your image based on another image, then your image would be the layers of base image combined with layers specified in your Dockerfile.
Each line of the output logs the status for a specific layer. And the hashes are those layers' IDs. Looks like your image is built on top of serviceA or serviceB and they're related as well. In this case your image would be a combination of layers defined by you plus the layers in the base images (serviceA and ServiceB). And when you're pushing your newly built image to the remote Docker registry, which has serviceA and serviceB already, Docker will copy only your layers. The other layers are already present in the registry and they will be reused (mounted) for your new image.
Upvotes: 1