I need a clarification about swarm mode

I need a clarification about swarm mode

Isn’t it good idea to develop an app in swarm mode from ground zero?
Deploying to swarm is necessary when the development is completed.
Is swarm mode only for production? Not development


I like the question.
The recommended way by Docker is to use docker-compose up ... (i.e. not Swarm-based) for local development, and then docker stack deploy ... (Swarm-based) for deployments in the CI \ CD pipeline.

I don’t like it and I have never followed it, as it breaks one of the core best practices of Continuous Delivery - use all environments in the same way, including Dev environment.

The differences between Dev and CI \ CD environments always cause the class of problems usually called “but it works on my machine”. People waste time on fixing those problems.
For instance docker compose format version 2 (compose) is very different from version 3 (Swarm).

I always developed with the Swarm mode straight-away.

fully agree! Otherwise you will end up maintaining two different compose files and realizing some problems at a very late stage:

  • synchronisation between containers: unpredictiable start order of containers and availability of services

  • make sure you work with external created volumes, not just only on the production system, but also on the development machine.

  • configurations and secrets are not available in Docker Compose and result in messy volume mounts

  • members of the team will be used to the syntax and more likely to support on swarm specific problems

To be considered during development:

  • if you aim for scale out with your application , make sure you start early to adopt the required patterns. Scale out with stateless apps is not possible, if they are not build to support it.

  • don’t forget to make your application load balancer friendly :wink:

1 Like