TechnologyTrueNAS - Scale

TrueNAS Scale – Use Vanilla Docker

By December 15, 2021May 6th, 20229 Comments

Edit- 3/26/2022 – This does INDEED work on 22.02 release versions. However- you can leverage docker-compose using the built-in apps now: https://www.truenas.com/community/threads/truecharts-integrates-docker-compose-with-truenas-scale.99848/

Introduction

This article simply outlines the steps required to use vanilla docker on TrueNAS Scale, instead of the built-in apps system.

This article is for you IF….

  1. You wish to use a normal, vanilla docker experience.
  2. You do NOT like kubernetes, and wish to use normal docker, or docker swarm.
  3. You are a TECHNICAL INDIVIDUAL, who is capable of troubleshooting.

This article is NOT for you IF….

  1. You wish to be supported by IX-Systems. The below steps, are completely unsupported.
  2. You want to use the built-in apps interface. This will break that.
  3. You want to just point and click on the GUI to install plex. This is a hands-on process, for people familiar with managing docker via the CLI, or portainer.
  4. You do not know what SSH, CLI, Bridges, Bonds is.

First Steps – Startup Scripts.

To use a vanilla docker experience, we first need to create a few scripts, intended to configure your docker experience.

The first step, is to build a docker/daemon.json file. Lets store this in a persistent directory. I personally use… /mnt/Main/Home/root

{
        "data-root": "/mnt/Flash/docker",
        "exec-opts": ["native.cgroupdriver=cgroupfs"],
        "storage-driver": "zfs",
        "iptables": true,
        "bridge": "",
        "dns": ["10.100.4.1"]
}

Make sure to update the DNS IP address to your DNS server.

Lastly, set the data-root to a persistent dataset on your system. Docker will store ALL of its images, volumes, and configuration here.

Next, we need a script to start, and configure docker.

This script does three things.

  1. Stops docker service if it is running.
  2. Remove any docker/daemon.json if it exists.
  3. Copies the daemon.json we created earlier to the proper location.
  4. Starts docker via systemctl.
systemctl stop docker
rm /etc/docker/daemon.json
cp docker_config.json /etc/docker/daemon.json
systemctl start docker

At this point, if you invoke the above script, it should startup a fresh copy of docker.

If you run

docker ps

It should return back an empty table, with nothing running. If not, something isn’t correct. Make sure your modified docker/daemon.json file has a new/fresh dataset that was not in use by the built-in apps before.

Next – Install Portainer

I keep a script handy for installing and upgrading portainer.

This script will stop portainer if it is running. and remove its container if it exists.

It will then install portainer, and create a docker volume named “portainer_data” if it does not exist.

NOTE- If you use portainer enterprise edition, replace portainer-ce, with portainer-ee

If you don’t use enterprise edition, portainer IS/WAS giving out free licensees for home users.

upgradeportainer
docker stop portainer
docker rm portainer
docker pull portainer/portainer-ce:latest
docker run -d -p 9000:9000 \
--name=portainer --restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest

After you have your script saved, chmod+x upgradeportainer to make the script executable, and then…. execute it.

Docker will proceed to download portainer, and install/run it.

From this point…. open a web browser and navigate to…. https://YourTrueNASHost:9000/ and you should see portainer.

That’s it!

From this point out, you can now manage docker either directly, or via portainer. If you wish to revert to the built-in apps, just delete your /etc/docker/daemon.json and restart the docker service.

Other Steps

https://jira.ixsystems.com/browse/NAS-115010

Scale 22.02.1 “Disables” docker-compose by default. If you wish to “Re-enable” docker-compose, you need to…

chmod +x /usr/bin/docker-compose
chmod +x /bin/docker-compose

Join the discussion 9 Comments

  • XO says:

    You can leverage macvlan networks, for exposing your servers with a dedicated IP address.

    docker network create -d macvlan –subnet=10.100.1.0/24 –gateway=10.100.1.1 -o parent=eno1 MyNetwork

    I will note, make sure you enable iptables within daemon.json, otherwise, you will have a lot more issues.

  • Stefano says:

    Hi guys, thanks for your help. I’m having a lot of issues related to how docker behaves with networks. Not able to use “host” network (i.e. with Plex or Home Assistant). sligtly better with bridge. Any other trick on daemon.jason to fix that?

    Thanks,
    Stefano

  • Jon says:

    Error message logged: level=error msg=”AUFS was not found in /proc/filesystems” storage-driver=aufs
    Any help?

  • SchSch says:

    Im super new to using TrueNAS scale, but one very important point for me is to use docker vanilla.
    My TrueNAS SCALE is installed on a relatively big SSD
    Will i run into problems if i will add a (for example EXT4) partition in my system ssd and use this path then for my data-root?
    Or even an USB stick simply plugged into my system?

    Not sure what this would mean in the boot-process

    • XO says:

      PERSONALLY, I wouldn’t.

      I personally keep my boot drive separate from my data. Its also strongly discouraged to use a usb stick for booting. You don’t need a large boot drive, 32G is more then enough.

      While many have partitioned the boot drive, and stored data on it, I personally just wouldn’t recommend it. But, it is completely possible.

      I keep everything separate. That way, if my boot drive gets corrupted, and I need to reinstall, there isn’t a hidden risk of me losing the OTHER data stored on it.

  • Spinningjenny says:

    Hey XO,

    i tried this script, but ran into the issue of “graphdriver plugins are only supported with experimental mode” when i used dockerd -D because docker was not starting. However, it did start using zfs as storage driver. Do you know a fix or have you run into this issue, because it seems like it only accepts zfs?

    Best regards,

    Spinningjenny

Leave a Reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 93 other subscribers

%d bloggers like this: