Have you heard people talking about Docker but have no idea what it is or if you need it? Docker is a fantastic tool that I think belongs in every homelab—here’s what Docker is, and why it is the one tool that makes my homelab easy to manage.What is Docker? No, it’s not the name of a container Close Docker is the name of a platform that containers run on.It’s both a command-line tool and a desktop interface, depending on which you prefer to work with.
Docker has become the industry standard for running containerized apps in both homelab and production environments.The Docker Hub, a repository of over 10,000,000 (10 million) public images, is also one of the go-to places to get applications to run inside Docker (or any other container manager).Docker is one of the most well-known container managers, which also makes it one of the best-documented options to use.
If you’re just getting started with containers, I’d highly recommend using Docker as your entry, it’s simpler, and the community has a ton of support available.What are containers, and are they exclusive to Docker? Docker is popular, but not the only player in town Docker helped to create the Open Container Initiative, or OCI, that a lot of other platforms now utilize.While Docker itself might not be free and open source in its entirety, the OCI that it helped start is.
For those who don’t want to use Docker, there are definitely other OCI-compliant platforms out there, including Podman, Containerd + Nerdctl, Rancher Desktop, or even LXC.Some of these programs run on the Docker subsystem, and others use their own implementation of containers.At the end of the day, though, they all run containers.
The easiest way to explain what a container is, is to reference it as an application.Each container image is designed to typically do one or two things, and that’s it.You can build your own images that do more, but it’s generally recommended to use single-purpose containers.
Each container you run will have both persistent storage that’s stored either in a Docker volume or in a folder on your computer, and storage that will be destroyed each time the container is updated.This makes containers easier to use than dedicated applications in many scenarios, because your preferences are stored in an easy-to-find file, and if you uninstall the container by accident, you can reinstall it and keep all your settings just as they were.How containers differ from virtual machines Pre-configured and ultra lightweight If you’ve never heard of or used a container before, one of the best ways to describe it is a lightweight virtual machine—but it’s a virtual machine.
A container is a containerized miniature operating system running on your computer that’s pre-configured to run the specific application it’s built for.This means you could get a container for Plex that’s based on the Arch Linux image, but it only includes the necessary components of Arch to run Plex and no more.Containers also can easily interact with your host operating system, while that’s often more difficult for virtual machines.
With containers, you’re often mounting folders or files from the host computer for it to read or even read/write from.Often, containers will have you mount something like an internal /data or /config folder to a folder on your computer.Doing so allows you full access to those files, and is actually why containers are so robust.
Just the other day, I did something to my Docker server that brought several containers down.All I had to do was start them back up fresh and point the mounted folders to the folders on my storage, and the services were back up and running like they never stopped.Running your very first container It’s easier than you think Running a Docker container is actually very simple.
You have two primary ways to run a Docker container: the docker run command, or through Docker Compose.I haven’t been a big Docker Compose user in the past, but I’m starting to use it more and more.For simplicity’s sake, I’m going to show you how to use docker run Docker Compose, so that you can easily see an example of both.
Start out by installing Docker on your computer.This varies based on what operating system you’re running, but once you have it installed, you’re ready to deploy your first container.With Docker installed, head to your terminal and run sudo docker run hello-world.
This should give you an output that shows a message from Docker with the steps it took to generate it.On the Docker Compose side of things, make a very simple docker-compose.yml file with the following code and then run docker compose up: services: hello: image: hello-world So long as you see an output similar to my screenshot above, you’re ready to move onto the next step in your Docker journey! Docker Compose can simplify your workflow Copy a file, change some lines, start your services I just showed you how to use both docker run and Docker Compose, but Docker Compose is really what you should use if at all possible.It’s a simpler method, especially with more complex deployments.
With Docker Compose, you can take your time to build a single file for the Docker container you’re wanting to launch.Modifying a Compose file is also very easy to do.With a docker run command, if you need to change a deployment setting (environmental variable, port, bind mount, or anything else), then you need to stop the container, rewrite the docker run command, and redeploy it.
With Docker Compose, you have the docker-compose.yml file inside a folder that you want to run the container from.The file itself is easy to change at any time.To launch the container, you either run docker compose up to just run it once and shut it down, or docker compose up -d if you want the container to run in the background.
If you make changes to the Compose file, docker compose up -d again, and now those changes take effect.Unless you’re using a web UI for Docker like Portainer (which I do), Docker Compose is simply the easiest way to interface with Docker.You can easily make changes to a container’s settings and redeploy it without having to try and remember what your original command looked like.
Trust the process Docker is an extremely valuable tool.In fact, Docker runs my entire homelab.I wouldn’t be able to run the services that I do without Docker.
If you haven’t used Docker before, then give it a try.It’ll revolutionize how you deploy and maintain services in your homelab (or production) environment.
Read More