Need a Summer Weekend Project? Try Docker
IF YOU WANT to make the most out of a VPS, home server, or NAS, learning how to use a container system, such as Docker makes life a lot easier, especially if you want to run multiple web apps, such as WordPress or Plex. Luckily, containers aren’t so scary to learn or use….
I used to be skeptical about the whole container and Docker thing. “Why would I want a container when I can just install things like I’m used to?” I would ask the void. The answer is pretty easy to understand when you try to install more than one app.
If you’ve ever run a server at home or on a shared host, upgrading an app can be a touchy experience. Some applications rely on specific features of their dependencies, or software that the app relies on to run. When upgrading your app, the new version may rely on an updated dependency. But if you’re running another app alongside your web application—like a database, for example—that app may cease to function properly if the dependency is upgraded.
Another situation is common: A web app—such as WordPress—updates itself, but requires a new version of some underlying software, such as PHP. If you upgrade too soon, your distro may not have the new version of the dependency available in its repositories, leaving you with errors in the web app.
Containers solve this problem by doing something that had before been the preserve of virtual machines. Unlike virtual machines, containers don’t require exclusive and pre-allocated CPUs or memory. Containers can use the current machine’s kernel, but simulate the rest of the OS’s filesystem. Essentially, an Ubuntu Docker container can run on a Fedora system. From within the container, it appears as though the system is running Ubuntu, with its own versions of Python, PHP, or any other apps it needs.
Updating a container does not require you to update the system. An updated container gives you the whole shebang: the app and its dependencies. Containers also have their own networking facilities and IP addresses on the host system. This allows containers to talk to one another through ports—like port 8096 for Emby. Docker networking also allows the use of Docker containers as training tools.
With all this goodness, should you run Docker containers at home? It depends. If you’re trying to run multiple services like Sonarr, Plex, and MySQL on one machine, I’d say yes. Many of the containers you’ll find on Dockerhub have pretty sane defaults. As it’s painless to start, stop, and delete containers, it won’t take long to get most things right.
Is there a downside? You bet. For a start, it’s another technology to learn. Some of the more advanced features of Docker containers can be tricky to use. Getting volumes, networks, and other configs set up just right can be a pain. And Docker for Linux does not work on the Windows Subsystem for Linux.
On top of this, Docker containers aren’t secure by default, as they run as root. This can be mitigated by running Docker with user namespaces, but the setup and administration consequences are non-trivial. Recently, several images hosted at Dockerhub were removed because the images contained crypto miners and other malware. As a rule, I try to use official container images or images from www.linuxserver.io.
The best part about Docker containers is that they’re (generally) free. Take time to experiment. They aren’t as scary as you might think.
Because it’s painless to start, stop, and delete containers, it won’t take long to get most things right.
Running a minimal Docker container image is a simple command.