How to install Sonarr Radarr and Jackett with Docker-Compose
3rd April 2019 4 By George WouContinuing from how to install sonarr radarr and jacket with docker, we’ll see how to combine the three services into a docker stack.With docker Compose we will be able to update the docker images and run the respective containers with a single command.
The whole process involves installing docker Compose and creating a yaml file that contains the parameters of the containers.
Install Docker Compose on Debian
In debian installation is straighforward.Download the script:
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Substitute 1.23.2 with the current Compose version , check latest version here and skip the RC versions.
The script is downloaded in /usr/local/bin/ and we need to make it executable:
sudo chmod +x /usr/local/bin/docker-compose
Test that it is working:
docker-compose -v
Install Docker Compose on Alpine
Per Ponyo Dogg’s comment the package is now included on Alpine so we can just run:
apk add docker-compose
and skip the rest of this section 🙂
On Alpine there is no package for docker Compose and following the official guide for installing on Linux will not work.So we will install docker Compose as a docker container.
Download the script:
sudo curl -L --fail https://github.com/docker/compose/releases/download/1.23.2/run.sh -o /usr/local/bin/docker-compose
Substitute 1.23.2 with the current Compose version , check latest version here and skip the RC versions.
The script is downloaded in /usr/local/bin/ and we need to make it executable:
sudo chmod +x /usr/local/bin/docker-compose
Test that it is working:
docker run --rm docker/compose:1.23.2 -v
As you can see we executed docker Compose using a docker command .This can become tedious so we will create an alias to make Compose execution similar to the normal installation method. Additionaly we use the –rm option which removes the container after running it or else we’ll end up with needless docker containers each time we execute the command.
The shell used by Alpine is ash.We will create an alias specific to the user dockeras by creating a file and adding the following lines in /home/dockeras/ directory:
nano ~/.profile
echo alias docker-compose="'"'docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$PWD:/rootfs/$PWD" \
-w="/rootfs/$PWD" \
docker/compose:1.23.2'"'" ~/.profile
With this alias every time we execute the command docker-compose a container with the specific options will be run.
It tells the container to use the unix socket of the docker daemon,something we include in containers that need to do stuff with the docker daemon of our host like monitor/manage docker containers e.g. portainer, or in our case docker Compose that will in essence claim docker actions for the apps we’ll specify later on.The -v and -w options specifies the temporary host and internal dirs respectively to store and access data.
These options are required for Compose to recognise the docker-compose.yml file we are going to setup later or it will throw errors.Also for the time being it seems that you can not use the -f flag effectively when Compose is installed as a docker image, so commands will have to be run from the directory the docker-compose.yml file resides.
Save and exit,now there should be a hidden file .profile in /home/dockeras:
ls -lah
Reload the shell configuration:
source ~/.profile
Run the test command again but this time like debian:
docker-compose -v
Now we can run docker Compose commands with the proper format.
Configuration of docker-compose.yml
After installing docker Compose and verifying it is working we can create the docker-compose.yml file that contains our containers configuration.
Go to the /home/dockeras directory and create and edit docker-compose.yml:
sudo nano docker-compose.yml
Since this article builds on the previous posts we’ll use the same example options.Copy the following lines and change accordingly:
version: '3'
services:
radarr:
container_name: radarr
restart: unless-stopped
ports:
- 7878:7878
volumes:
- /home/dockeras/radarr:/config
- /mnt/downloads:/downloads
- /mnt/synomovies:/movies
environment:
- PUID=1000
- PGID=150
- TZ=Europe/Athens
image: linuxserver/radarr
sonarr:
container_name: sonarr
restart: unless-stopped
ports:
- 8989:8989
volumes:
- /home/dockeras/sonarr:/config
- /mnt/downloads:/downloads
- /mnt/downloads:/tv
environment:
- PUID=1000
- PGID=150
- TZ=Europe/Athens
image: linuxserver/sonarr
jackett:
container_name: jackett
restart: unless-stopped
ports:
- 9117:9117
volumes:
- /home/dockeras/jackett:/config
environment:
- PUID=1000
- PGID=150
- TZ=Europe/Athens
image: linuxserver/jackett
portainer:
container_name: portainer
restart: unless-stopped
ports:
- 9000:9000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/dockeras/portainer:/data
environment:
- PUID=1000
- PGID=150
- TZ=Europe/Athens
image: portainer/portainer
YAML is indentation dependent so be careful.When editing in notepad++ for example, tab is a no go, just use spaces.
To check that the file is readable by Compose do:
docker-compose config
If there is an error message similar to this:
ERROR: In file ‘./docker-compose.yml’, service must be a mapping, not a NoneType
we need to check the indentation of the lines we pasted.
Additionally i added portainer configuration which is an awsome gui for managing our containers,check stats and create docker compose setups. Currently up to compose version 2 is supported and if we do it externally like in the example we cannot pull/update the stack through the portainer gui,but we can still manage containers belonging to our compose stack individually.(Update:Read comments)
For Compose to take over and manage the specific containers, we need to stop and remove these containers, but it is not necessary to remove their respective images.
Check which containers we have , running or not:
docker ps -a
Stop active containers and remove all the containers we intend to include in the docker-compose.yml file. No data will be lost when removing them:
docker stop jackett portainer
docker rm sonarr radarr jackett portainer
Now we can update the images and run them with docker compose:
docker-compose pull && docker-compose up -d
In this one liner Compose checks if newer images exist in docker hub, downloads them, and runs all the containers again since Compose controls them now.
But the next time we will run Compose, it will again check for newer images and it will only run the containers that had an update.With Compose we save time since we dont have to manually stop and remove containers, download new images and run the container again.
We can also selectively update containers:
docker-compose pull sonarr && docker-compose up -d sonarr
To remove leftover older images do:
docker image prune
Conclusion
With Docker Compose, like with Docker, we can preserve containers data in our storage, update only containers having a newer image and document the configuration of all our containers in one file.The whole process of shutting down, updating and starting all our containers is accomplished in one line.
Reference:
https://docs.docker.com/compose/install/#install-as-a-container
https://cloud.google.com/community/tutorials/docker-compose-on-container-optimized-os
4 Comments
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
To get portainer to operate on docker-compose v3+, you need to convert the host machine to a swarm manager.
More details can be found at:
– https://docs.docker.com/get-started/part3/
– https://github.com/portainer/portainer/issues/2054#issuecomment-417841575
Thanks for the heads up!
https://www.portainer.io/2019/06/portainer-release-1-21-0/ on comments section
docker-compose is now a package for Alpine Linux.
Just run:
apk add docker-compose
nice,at last!