I've been using Docker a lot lately...

I've been using Docker a lot lately...
Photo by Rubaitul Azad / Unsplash

You wouldn't believe how many services I run utilize Docker on a host machine somewhere. Maybe it's too many, maybe it's just enough. I'd be lying if I said I completely understood Docker, though.

Why Docker?

Why anything else? To me, Docker is super easy to use and get services up and running really quickly. It does take some knowledge to get a whole lot of web services running on the same host, though.

Sure, I know Ansible exists but I suppose I just attached to Docker first. And before you point it out – I know Docker and Ansible aren't "really" comparable to each other. They do different things. Docker is what I'll call a containerization platform, whereas Ansible is more of an orchestration tool.

What do I run?

Is a question you might be asking. Well, it's not a small list, but here's what I currently run in my Docker environment:

  • Authentik - User authentication
  • Discord Bots - Based on Red using this Docker image
  • Ghost - This blog!
  • Nextcloud
  • Remotely - Remote management platform
  • Send - File sharing
  • UptimeKuma - Uptime tracking
  • Vaultwarden
  • Wordpress

An Important Note

I won't be going into detail about this in this blog post, but when running multiple Docker containers with different services, obviously you can't run them all on the same port.

That where Caddy comes in. Caddy is the reverse proxy that route all the traffic from the appropriate domain to the correct Docker container on a specified port.

For example, say I have multiple instances of Ghost running on the same host. I can't set both containers to use host networking because each one would try to listen on the same port. Assuming they're both wanting to run on port 80, I'm able to do something like this:

  • On Docker container 1, I can assign it host port 5000
  • On Docker container 2, I can assign it host port 5001
  • Both Docker containers then route internally to port 80 in each container

Now with Caddy, I can make a simple Caddyfile with the following:

ghost-1.example.com {
    reverse_proxy :5000

ghost-2.example.com {
    reverse_proxy :5001

Et voila! Now there's a webserver running on the host machine that will proxy the traffic to the appropriate Docker container without the need to specifying a pesky port in the URL.

Don't worry, I'll make a blog post on how I use Caddy so that you can get started with it too!

So That's It.

I suppose I don't have much more to add other than if you're not already using Docker, you should give it a shot! Sure it's kinda daunting at first, but I've gotten used to using docker-compose for almost everything. They're also super easy to back up!