Reputation: 41
I have setup a 3 node cluster (with no Internet access) with 1 manager and 2 worker-nodes using the standard swarm documentation.
How does the swarm manager in swarm mode know about the images present in worker nodes?
Lets say I have image A in worker-node-1 and image B in worker-node-2 and no images in the manager-node.
Now how do I start container for image A using the manager? Will it start in manager or node-1?
When I query manager for the list of images will it give the whole list with A and B in it?
Does anyone know how this works? I couldn’t get the details from the documentation.
Upvotes: 2
Views: 400
Reputation: 2367
Docker Swarm manager node may be a worker one by second role but it is not strictly necessary.
Image deployment policy is mapped via docker-compose.yml
, which has an information about target nodes, networks, hostnames, volumes, etc. in relation of a particular service. For example, it may propagate the deployment either over fixed or emptiest node.
Swarm manager communicates with the worker nodes via Docker networks:
When you initialize a swarm or join a Docker host to an existing swarm, two new networks are created on that Docker host:
- an overlay network called ingress, which handles control and data traffic related to swarm services. When you create a swarm service and do not connect it to a user-defined overlay network, it connects to the ingress network by default
- a bridge network called docker_gwbridge, which connects the individual Docker daemon to the other daemons participating in the swarm.
During Swarm deployment the services are propagated to worker nodes according to their deployment policy.
The manager node will contain images once the node is the worker one too.
Upvotes: 0
Reputation: 1158
Run the docker stack deploy
command with --with-registry-auth
that will give the Workers access to pull the needed image
By default Docker Swarm will pull the latest image from registry when deploying
Upvotes: 0
Reputation: 263469
The default configuration with swarm mode is to pull images from a registry server and use pinning to reference a unique hash for those images. This can be adjusted, but there is no internal mechanism to distribute images within a cluster.
For an offline environment, I'd recommend a stand alone registry server accessible to the cluster. You can even run it on the cluster. Push your image there, and point your server l services to the registry for their images to pull. See this doc for details on running a stand alone registry, or any of the many 3rd party options (e.g. Harbor): https://docs.docker.com/registry/
The other option is to disable the image pinning, and manually copy images to each of your swarm nodes. You need to do this in advance of deploying any service changes. You'll also lose the benefit of reused image layers when you manually copy them. Because of all this issues it creates, overhead to manage, and risk of mistakes, I'd recommend against this option.
Upvotes: 0