Right now I'm using Docker Compose to host 15-20 services for my home lab. All of these are running on a single machine which is physically in my house. I have no interest in scalability (i.e. replicating my services to different nodes), but I was told that Docker Swarm would be a good step in the right direction over Compose. It also means that I can use Portainer to control my stacks (since I use compose v3 format, they do not support it).

Right now I run a cron job on my system that does the following for each stack running on my system (i.e. each docker-compose.yml):

  1. docker-compose down all the services
  2. Back up the volumes (physically zip them and copy them to a NAS)
  3. docker-compose pull to get the latest images
  4. docker-compose up -d to restart everything.

Note that this process restarts containers even for services that had no new image update. This is important because some containers are designed to internally update their software at entrypoint.

If I use Docker Swarm, even for a single machine, does it allow this type of automation to be performed more easily? I see that there is a swarm update command, but it looks very confusing and I'm not sure if it provides the functionality I've described above (excluding the backup part).

Can I use Docker Swarm to automate updating images of services and recreating containers to keep them updated? If so, how can I do that? Examples would be very helpful!

  • I think in your case, swarm will mostly provide the benefit of being able to attach a dashboard like portainer or swarmpit. Other than this, since you do not need scaling, it will be pretty identical to your compose setup, but somewhat more confusing. Don't think swarm update will be helpful here. Using swarm locally on one machine is quite easy to test - just docker swarm init and you can already use your existing compose files to start a stack. – DannyB Apr 10 at 20:15
  • Thanks @DannyB. Unfortunately I'm worried that some things I'm doing in my docker compose YML files is incompatible in swarm mode. I haven't seen a comprehensive list of things that don't work in swarm mode. That would be extremely helpful. – void.pointer Apr 11 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.