Home Docker Server

As per the norm, I will skip the bumf and jump straight in to the process I used as you should know what you are doing, if not go off learn and come back

  1. Install Ubuntu Server 18.04 LTS:
    1. Download here: https://www.ubuntu.com
  2. If not installed during Setup, Install the following:
    1. OpenSSH Server: Instructions here
    2. Samba: Instructions here
    3. Standard Utilities: sudo apt-get install ubuntu-standard
    4. Udev (required for Plex & LiveTV: sudo apt-get install udev
  3. Update to ensure everything is the latest
    1. sudo apt-get update
    2. sudo apt-get upgrade

  1. Install Docker:
    1. sudo su
    2. apt-get install apt-transport-https ca-certificates curl software-properties-common

    3. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

    4. add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

    5. apt-get update
    6. apt-get install docker-ce
    7. docker run hello-world
  2. Install Docker Compose:
    1. Check latest version here – https://github.com/docker/compose/releases and change version in next step
    2. sudo curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-compose

    3. type “exit” to exit su mode
    4. sudo usermod -aG docker ${USER}
    5. type “id” hit enter and note the uid of your user & gid of docker
    6. type “cd ~ ; pwd” hit enter and note location of user directory
    7. sudo nano /etc/environment
    8. Replace/Configure & save with the following:
      “PUID” & “PGID” as listed above
      “TZ” as listed here
      “USERDIR” of the docker user
      “MYSQL_ROOT_PASSWORD” for MariaDB and phpMyAdmin
PUID=1000
PGID=1000
TZ="Europe/London"
USERDIR="/home/<USERNAME>"
MYSQL_ROOT_PASSWORD="password"
    1. Type “exit” hit enter and log back in
  1. Basic Docker & Docker Composer
    1. sudo mkdir ~/docker
    2. sudo setfacl -Rdm g:docker:rwx ~/docker
    3. sudo chmod -R 775 ~/docker
  2. Create basic Docker Compose File
    1. sudo nano ~/docker/docker-compose.yml
    2. Add the following:
version: "3.6"
services:
###########
# mariadb #
###########
  mariadb:
    image: linuxserver/mariadb:latest
    container_name: mariadb
    hostname: mariadb
    restart: always
    network_mode: host
    volumes:
      - ${USERDIR}/docker/mariadb:/config
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
#############
# Portainer #
#############
  portainer:
    image: portainer/portainer:latest
    container_name: portainer
    hostname: portainer
    restart: always
    command: -H unix:///var/run/docker.sock
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${USERDIR}/docker/portainer/data:/data
      - ${USERDIR}/docker/shared:/shared
    environment:
      - TZ=${TZ}
##############
# watchtower #
##############
  watchtower:
    image: v2tec/watchtower
    container_name: watchtower
    hostname: watchtower
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: --schedule "0 0 23 * * SUN" --cleanup
##############
# phpmyadmin #
##############
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    hostname: phpmyadmin:latest
    restart: always
    links:
      - mariadb:db
    ports:
      - 82:82
    environment:
      - PMA_HOST=mariadb
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}

Why not check out my docker-compose.yaml here. I highly suggest installing the following:

      • Portainer – Container Management
      • Organizr – Tabbed web interface for all your containers
      • Watchtower – Automatic Container updating

You may also want to check out this article here on mounting external storage if you are using Plex, ZoneMinder etc

  1. Starting docker compose
    1. sudo docker-compose -f ~/docker/docker-compose.yml up -d
Advertisement
%d bloggers like this: