How images work in swarm mode?

I’m a little confused how images are being used in Swarm mode. I expected it to see all intermediate images downloaded to worker nodes but all I see is latest version of image of my service. How is it going to work if I have the same base image for a lot of different services running on the same worker node. Does it mean each of those will have to be pulled separately?

They are not handled different than without swarm mode.

First of all when you create a service it will check for the current image locally. When it finds it, it’ll pin it’s SHA256 and will send this pinned version as “to use version” to all nodes that get a tasks of this service assigned. The worker node then downloads the image from the registry if it’s not present. And then starts using it.

If you use the same base image for multiple containers, as always it’ll download the layers the first time and them simply notice that it can reuse them, thanks to hash-based layered filesystem.

That’s it.