7 Docker Containers
abuhamsa edited this page 2020-11-18 10:42:23 +01:00

Intro

If you're running Ombi in a Docker container, then chances are you're running other services in one as well.
There are things to consider when doing this - primarily, how are your containers going to communicate with each other/other machines?

Installation

Direct Command

If you just want Ombi to run, it's entirely possible to do this without having to do much actual configuration.
You'll (ideally) need a location mounted for Ombi to put config files (/opt/ombi/config/ tends to be a good option on linux based systems).
To create the folder and run Ombi on port 3579 (the default for v4), run the following from the terminal/shell:

mkdir -p /opt/ombi/config/

docker run -d --name=ombi -p 3579:3579 --restart=unless-stopped -v /opt/ombi/config:/config linuxserver/ombi:v4-preview

This will create the folder and a container named "ombi" that you can then manage like any other docker container.
If you wish to use mysql as a database for ombi, then you'll need to create a "database.json" file in the config folder created before.
Details for the file can be found here.

Docker Compose

Here an example of a docker-compose stack with Ombi, MySQL and phpMyAdmin. Please remind yourself that this is just an example and can/should be changed to your needs:

  1. Create an folder for your "/config"-volume and for the MySQL-container
mkdir -p /opt/ombi/config/
mkdir -p /opt/ombi/mysql/
  1. Create a "database.json"-file in the folder from step 1 with this content --> see:
{
  "OmbiDatabase": {
    "Type": "MySQL",
    "ConnectionString": "Server=mysql_db;Port=3306;Database=Ombi;User=ombi;Password=ombi"
  },
  "SettingsDatabase": {
    "Type": "MySQL",
    "ConnectionString": "Server=mysql_db;Port=3306;Database=Ombi_Settings;User=ombi;Password=ombi"
  },
  "ExternalDatabase": {
    "Type": "MySQL",
    "ConnectionString": "Server=mysql_db;Port=3306;Database=Ombi_External;User=ombi;Password=ombi"
  }
}
  1. Create a "docker-compose.yml"-file in the folder from step 1 with this content:
---
version: "2"
services:
  ombi:
    image: ghcr.io/linuxserver/ombi:v4-preview
    container_name: ombi
    restart: unless-stopped
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Zurich
    volumes:
      - /opt/ombi/config:/config
    ports:
      - "3579:3579"
    depends_on:
    - "mysql_db" 
    
  mysql_db:
    image: "mysql:5.7" #maybe switch to a newer one, I've tested it with this image
    container_name: ombi_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 123 #change your root password here
    volumes:
      -  /opt/ombi/mysql:/var/lib/mysql      
      
  phpmyadmin:
      image: phpmyadmin/phpmyadmin
      container_name: ombi_phpmyadmin
      restart: unless-stopped
      environment:
        PMA_HOST: mysql_db      
      ports:
       - '8080:80'
      depends_on:
       - "mysql_db"
  1. Run docker-compose to start this stack:
cd /opt/ombi/config
docker-compose up -d
  1. Open the phpMyadmin website "http://docker-host-ip:8080/server_sql.php". Login with root and your chosen password. Then run the following commands:
CREATE DATABASE IF NOT EXISTS `Ombi` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE DATABASE IF NOT EXISTS `Ombi_Settings` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE DATABASE IF NOT EXISTS `Ombi_External` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'ombi'@'%' IDENTIFIED BY 'ombi';
GRANT ALL PRIVILEGES ON `Ombi`.* TO 'ombi'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON `Ombi_Settings`.* TO 'ombi'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON `Ombi_External`.* TO 'ombi'@'%' WITH GRANT OPTION;
  1. Stop the stack and start it again:
cd /opt/ombi/config
docker-compose down 
docker-compose up -d
  1. Open Ombi "http://docker-host-ip:3579" and Setup your ombi-installation

Considerations

Host vs Bridge Networking

Host

Host networking gives the container direct access to the network adapter of the host machine (the one running Docker).
This means that the container runs like any other network application, with complete freedom to discover other devices/services on your network. It is appropriate for some systems (like Home Assistant), but one of the benefits of Docker is the 'isolation' of services (so nothing depends on anything else).

Bridge

Bridge networking makes the Docker Host behave like a VM Host and a router, with a whole separate virtual network behind its own LAN IP.
Each container then gets an IP in a whole different IP range than your LAN itself. Usually, Docker uses 172.17.0.x for these. If the Ombi container was given 172.17.0.3, then it would listen on 172.17.0.3:3579 (for example).
This means that you map ports from the host to the container, much like port forwarding for access from outside your network (as you would for passing ports 80 and 443 to your web server, for instance). The two ports do not have to be the same - you could map 3589 on your host to point to 3579 on your container.
To access the service from outside of the Docker host, you'd browse to the LAN IP of said host and the port you mapped - 3589 in the example above. Docker would see the traffic hit the host on 3589 and pass it through (via Network Address Translation, or 'NAT') to the container on 172.17.0.3:3579

Talking to Other Services

If you have an Ombi container, and a Sonarr container (or Radarr/Lidarr/CouchPotato etc), then these services will all need to talk to each other.
If you've configured your containers to use host networking, then all you'll need to do is use the LAN IP of the Docker host as the IP of the service.
However, if you've used bridge, then you can use either the container IP or the container name instead (as this stays inside the virtual network that the host created for all the containers to communicate via).
For example, if you have a Sonarr container named "sonarr" that has an IP of 172.17.0.17, then you could either enter "sonarr" or "172.17.0.17" as the address for Ombi to reach Sonarr.

Finding Container IP address

If you want to get the container IP, then you'll need to query docker for it.
Most GUI options for Docker will report it (Portainer is a good one).
If you prefer the CLI/console/bash/shell, then you can inspect the container that way with the below command:

docker inspect <container name> | grep "IPAddress"

If you don't recall what name you used for the container, then you can find out your container names with:

docker container ps