Docker Compose and Self-Hosting

Published: 2022-09-23

This site contains tutorials to run your own services. The aim is to host those services reliably meaning that backups should be automated and servers should be easy to re-install. For both these aims, Docker Compose (https://docs.docker.com/compose/) is a great fit. Once Docker Compose is installed, it makes it easy to run a wide variety of services. For example, NGINX, Ruby on Rails, or Gitea.

Docker Compose allows you to declaratively specify your services. This is great for re-installing them if needed, but also to make it easier to figure out where data is stored. For example, Docker requires you to explicitly say which data should be kept between restarts of the service. Next, you can use the paths to the data to figure out what needs to be included in the backup.

Setting up a service is as simple as defining a Docker Compose configuration and running:

$ docker-compose up

when setting restart: 'unless-stopped' in the configuration, it will automatically restart the service if the server for some reason restarts.

This is all very useful for hosting services which are used by a few people. Container orchestration tools such as Kubernetes are too complex for most situations.

If you want to learn more,

The text is licensed under CC BY-NC-SA 4.0 and the code under Unlicense.