26 Docker
bakerboy448 edited this page 4 years ago

Installing Docker

Start by getting Docker installed and working on your operating system of choice. There is no reason to go over that here since it is well documented at Docker's own site (and on FreeBSD's wiki). Once it is working, you'll be ready to move on.

Pick Stable or Nightly

Docker containers are intended to be static, they shouldn't self update internally. As such, releases are tagged and built under certain names. This allows for immutable versioning. If you want to use a stable releases, you want a tag that tracks as such. If you'd rather run the latest and greatest, nightly is the right choice. The docker pages have good setup and usage instructions, follow them.

  • Linuxserver.io: linuxserver/radarr
    • latest: Stable releases
    • 5.14: Stable releases, but run on Mono 5.14
    • nightly: Nightly releases
  • hotio: hotio/radarr
    • latest: Stable releases (the same as the stable tag)
    • stable: Stable releases (also versioned tags like stable-0.2.0.1358)
    • nightly: Nightly releases, new UI like Sonarr V3, .NET Core (also versioned tags like unstable-0.2.0.1448)

Using systemd

Using your favorite editor, create /etc/systemd/system/docker-radarr.service with the following systemd unit file. Be sure to replace timezone and path to data with the correct values. Note that ExecStart is basically the same command on the docker page for the image you choose, so adjust appropriately. This example uses linuxserver/radarr, but hotio/radarr is equally as valid.

[Unit]
Description=Radarr docker container
Requires=docker.service
After=docker.service

[Service]
Restart=always
RestartSec=30

ExecStart=/usr/bin/docker run --rm \
                              --name=radarr \
                              -v /path/to/config:/config \
                              -v /path/to/data:/media\
                              -e PGID=<gid> -e PUID=<uid>  \
                              -e TZ=<timezone> \
                              -p 7878:7878 \
                              linuxserver/radarr

ExecStop=/usr/bin/docker stop radarr

[Install]
WantedBy=multi-user.target

Firewall

An important network and firewall aspect to make note of is the difference between Docker's bridged and host network mode. The default is bridged, which then uses the -p option to open up a port to everything. If the host option is used instead, it'll obey any of your firewall rules. This distinction is most notable outside of a typical LAN environment, like with a VPS, dedicated server or AWS instance.

To change between options, just replace -p 7878:7878 \ with --network host \.

Set permissions

sudo chmod 644 /etc/systemd/system/docker-radarr.service

Enable and Start

sudo systemctl enable docker-radarr
sudo systemctl start docker-radarr

Check Status:

sudo systemctl status docker-radarr
● docker-radarr.service - Radarr container
   Loaded: loaded (/etc/systemd/system/docker-radarr.service; enabled; vendor preset: enabled)
   Active: active (running) since ma 2017-01-16 00:29:57 CET; 14h ago
 Main PID: 9946 (docker)
    Tasks: 7
   Memory: 3.7M
      CPU: 46ms
   CGroup: /system.slice/docker-radarr.service
           └─9946 /usr/bin/docker run --rm --name radarr --network=host -e PUID=1000 -e PGID=1000 -e TZ=<YOURTIMEZONE> -v ...

jan 16 00:30:01 server docker[9946]: -------------------------------------
jan 16 00:30:01 server docker[9946]: User uid:    1000
jan 16 00:30:01 server docker[9946]: User gid:    1000
jan 16 00:30:01 server docker[9946]: -------------------------------------
jan 16 00:30:01 server docker[9946]: [cont-init.d] 10-adduser: exited 0.
jan 16 00:30:01 server docker[9946]: [cont-init.d] 30-config: executing...
jan 16 00:30:01 server docker[9946]: [cont-init.d] 30-config: exited 0.
jan 16 00:30:01 server docker[9946]: [cont-init.d] done.
jan 16 00:30:01 server docker[9946]: [services.d] starting services
jan 16 00:30:01 server docker[9946]: [services.d] done.

Try going to http://localhost:7878 (if running locally) or http://ip.address:7878 in your browser.

Stopping

sudo systemctl stop docker-radarr

Update Docker Image

Execute the following commands:

sudo docker pull linuxserver/radarr
sudo systemctl restart docker-radarr

Using Helm

The Radarr team does not currently maintain a helm chart directly

A popular helm chart is maintained by the guys over at k8s@home. Installation, upgrade, and removal docs are all on the artifacthub.io page

Using Ansible

Ansible provides a simple module to manage docker containers. Here's a simple task that can get Radarr running.

- name: radarr container
  docker_container:
    name: radarr
    image: linuxserver/radarr:0.2.0.1316-ls4
    state: started
    restart_policy: unless-stopped
    published_ports:
    - "7878:7878"
    env:
      TZ: America/Los_Angeles
      PGID: 118
      PUID: 1000
    volumes:
    - /host/config:/config
    - /host/movies:/movies
    - /host/downloads:/downloads

PGID and PUID are the group and user id to run the container under.

Advanced

Automate Docker Image Update

If you want to automate this, you can use the following script (let it run with a systemd timer):

#!/bin/bash

images=(     linuxserver/jackett  linuxserver/radarr  linuxserver/sonarr )
containers=( jackett              radarr              sonarr             )
services=(   docker-jackett       docker-radarr       docker-sonarr      )

for ((i=0; i<${#images[*]}; i++)); do
    echo "Pulling docker image: ${images[i]}"
    docker pull ${images[i]}
    if [[ $(docker inspect --type=image --format='{{.Id}}' ${images[i]}) != $(docker inspect --type=container --format='{{.Image}}' ${containers[i]}) ]]; then
        echo "Restarting service: ${services[i]}"
        systemctl restart ${services[i]}
    fi
done

Modify the variables images, containers and services according to your system. This script will only restart a service/container if the docker image was updated by docker pull.

Cleanup

With these commands you can do some cleanup of docker images and containers:

# Remove all stopped containers
# Remove all volumes not used by at least one container
# Remove all networks not used by at least one container
# Remove all dangling images
# https://docs.docker.com/engine/reference/commandline/system_prune/#usage
sudo docker system prune 

# Remove leftover containers
sudo docker ps -a -f status=exited -q | xargs -r sudo docker rm

# Remove leftover images
sudo docker images --no-trunc -q -f dangling=true | xargs -r sudo docker rmi

# Remove dangling volumes
sudo docker volume ls -qf dangling=true | xargs -r sudo docker volume rm