1
votes

In Docker Swarm Mode (1.12+) it is possible to create so-called 'global' service, eg:

docker service create \
 --name redis_2 \
 --mode global \
 redis:3.0.6

Global service is active on each node.

What is the order of service creation when I add a new node to Swarm and when Swarm has some pending services to create?

Does Swarm guarantee that global service is created first (until its healthcheck passes), and only after that Swarm creates pending replicated services?

1

1 Answers

0
votes

No, there is no guaranteed order in which services are started. Best practice is to design your applications / services to be resilient against failures of other services. Keep in mind that services can be interrupted at any time during your application's lifecycle (services are updated, networks can be temporarily unavailable, nodes or even data centers can go down).

If a service depends on another service, you can (for example) implement a retry-loop; a simple example can be found in the official WordPress image, which has a retry loop to check if the database server is available, and accepting connections; https://github.com/docker-library/wordpress/blob/637afb53dc03b4af19149a0880e796346f97c137/php5.6/apache/docker-entrypoint.sh#L170-L181