In this post I'm going to show you how you can install Docker Compose version 2 on a Linux system and register a
Install Docker Compose
Docker Compose releases are available at the following Git Hub repository https://github.com/docker/compose/releases. This means we easily can download the binary for e.g. a 64 bit Linux operating system. In the example below I use
curl to perform the download and store it at
sudo curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o /usr/libexec/docker/cli-plugins/docker-compose
Now we need to make sure that the binary is executable.
sudo chmod 755 /usr/libexec/docker/cli-plugins/docker-compose
Install a Systemctl Service
Now I want to run my docker composition as a service to make sure the composition starts when the operating system starts. Therefore I create a new file
Description=My service with docker compose
WorkingDirectory=<path to your Docker composition
ExecStart=/usr/libexec/docker/cli-plugins/docker-compose up -d --remove-orphans
Finally we register the new service by executing
sudo systemctl enable myservice.service. Et voilà, the service is registered and can be started using
sudo systemctl start myservice.service.