Are databases a bad fit for Docker Swarm in production?

September 26, 2026 4 answers
Asked by measureRest16
I'm using Docker Swarm for several stateless services and it has worked well, but I'm struggling with persistent workloads such as PostgreSQL and Redis. Shared NFS volumes become a bottleneck under heavy I/O, while pinning a database to one node with placement constraints seems to create a single point of failure and defeats much of the benefit of orchestration. Is the practical approach to run databases as managed cloud services or on separate infrastructure, or have people successfully used distributed storage such as GlusterFS or Longhorn with Swarm? I'm wondering whether I'm missing a reliable Swarm pattern or simply trying to force the wrong tool to handle stateful workloads.

Answers

~jig4stop
In theory, Swarm can work with external storage systems through volume plugins and storage interfaces, but the integration is much less turnkey than in Kubernetes. Youโ€™ll likely be hand-building the storage integration, handling node recovery yourself, and validating performance and failure behavior under real load. A distributed filesystem may provide redundancy, but it can also add latency and another complex system to operate.

!open the hatch: Thatโ€™s the key distinction: moving or resynchronizing a volume between nodes isnโ€™t the same as providing database high availability. Swarm largely leaves the storage and recovery design to you.

Reply to this answer
close-up-lens
The simplest architecture is to treat databases as external dependencies. Use a managed PostgreSQL or Redis service when possible, or run them on dedicated machines with their own replication, backups, monitoring, and recovery procedures. This also lets the database and application have separate availability targets. Kubernetes operators can provide a more integrated stateful workflow, but they bring considerably more operational complexity, while Swarm remains a reasonable choice for smaller, mostly stateless deployments.

Gadzooks: For a small self-hosted environment, Swarm can still be a practical low-overhead choice. Iโ€™d just avoid assuming that moving to Kubernetes automatically makes database operations easy; the operator, storage platform, and recovery process still need to be operated correctly.

Reply to this answer
14 laps remaining
We run small, disposable Redis instances as single containers because the data can be rebuilt and the workload is limited. PostgreSQL is different: it runs in a dedicated high-availability cluster managed with PostgreSQL-specific tooling such as Patroni. That keeps database failover, replication, and health checks in the system designed for them instead of putting those responsibilities on Swarm.

+escape velocity: Patroni is a strong option, but it does add operational work. You still have to manage the cluster coordination layer, backups, upgrades, and failure testing, so itโ€™s worth comparing that cost with a managed PostgreSQL service.

Reply to this answer
high-and-dry
For serious production databases, Iโ€™d keep them outside the Swarm cluster. A separate PostgreSQL setup with solid backups, replication, and monitoring is usually easier to reason about than trying to make shared volumes and node pinning provide database availability. Swarm is excellent for stateless services, but it doesnโ€™t remove the need to design the storage and failover layers yourself.

.seltzer: That still leaves the question of high availability. If the separate database host fails, you need replication across multiple machines or youโ€™re accepting downtime. The important part is treating that as a deliberate database architecture decision rather than expecting the scheduler to solve it.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions