Docker tips & tricks
YOU’LL NEED THIS
DOCKER ENGINE, PLUS YOUR CHOICE OF CONTAINERS available for Linux, Windows, Mac, QNAP, and Synology
IF YOU FOLLOWED LAST ISSUE’S NAS SERVER BUILD, you’ll have been left hanging with the tantalizing prospect of using Docker to run many, if not all, of your key services. Docker provides a clever way to run a wide range of applications and network services (from VPN and self-hosted cloud-style backup to media streaming) on any supported hardware.
Docker containers make it easy to run services in isolated bubbles, complete with their own dependencies and with tailored access to the outside world. At first glance, it can appear an impenetrable subject but in this tutorial, we’ll show you how to install it on your system, set things up, get a firm understanding of the basics, and deploy your first containers, one to provide a convenient graphical front end, the other to set up a reverse proxy allowing you to securely access selected containers from outside your home network should you wish.
This tutorial focuses on those running a command-line version of Linux, such as Ubuntu Server as featured in last issue’s NAS build. But you can easily run Docker natively on other platforms too—just skip the steps on configuring a dedicated Docker user account.
NICK PEERS
1INSTALL DOCKER
Docker exists in many forms, such as Docker Desktop for Windows and Mac users, and Docker Engine for Linux command-line distros. Visit https://docs.docker.com/engine/ install/ to click the relevant link for your operating system to access downloads and specific installation instructions.
>> If you followed our advice from last issue’s NAS build, your server will be running a version of Docker supplied by Ubuntu’s own proprietary repository, snap. It works fine but isn’t updated frequently. If you’d prefer to switch to Docker’s repositories, simply follow the guide at https://docs.docker.com/engine/ install/ubuntu/ but ignore the ‘sudo apt-get remove’ command listed, substituting it with this instead: sudo snap remove docker >> Note, the installation process won’t remove any existing containers, images, volumes, or networks you have installed.
>> If you own a Synology or QNAP NAS, you can also install Docker on there—search for Docker (Synology) or Container Station (QNAP) in their respective app stores. Both provide their own user-friendly GUI interfaces for managing your containers, but you can also use our favored web-based front end, Portainer, if you wish.
2CONFIGURE ROOTLESS ACCESS
Docker in Linux works by ‘mapping’ the container’s internal user to your ‘root’ user, which isn’t great for three reasons: security, the fact any files created by the container such as configuration or data files—are owned by root (making them difficult to access), and the need to run Docker commands with the ‘sudo’ prefix.