I’m currently running, on top of my blog, a gogs instance.
When first creating this website, I just had my blog. I generated this blog using hugo: a static site generator. Hugo allowed me to focus on writing whatever I wanted in Markdown format, it would take care of converting my writing into HTML and CSS.">
I’m currently running, on top of my blog, a gogs instance.
When first creating this website, I just had my blog. I generated this blog using hugo: a static site generator. Hugo allowed me to focus on writing whatever I wanted in Markdown format, it would take care of converting my writing into HTML and CSS.">
<script>
if (localStorage.getItem("color-theme") === "dark" || (!("color-theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches)) {
wanted to be able to do a simple <code>git push</code>, and not worry about the rest.</p>
<p>The previous “manual” approach also depends on me having already installed all
necessary software. If you have a dedicated server that you’re running yourself,
that’s probably okay, you just have to setup once, but I’m running this on a VPS
that I’m not sure I’ll keep forever. The ability to reproduce this exact setup
within minutes actually matters.</p>
<p>After reading a bit on this topic, I decided I would use podman for this. Docker
would work just as nicely (any containerization software would work, really),
but I decided on podman because it can run without a daemon and without root
privilages. Also, it has pretty neat support for kubernetes pods (which are
honestly a lot more useful than I would’ve given them credit for before I started
this whole project).</p>
<p>That’s really why I’m writing this. So that you, the reader (or possibly my future self) can
understand the methodology of podman, how to create pods, run containers and configure all
of this automatically, and so that I may demonstrate and share what I’ve learnt during
this process.</p>
<h2id="motivation">Motivation</h2>
<p>Basically, I’m already running a web server. Why shouldn’t I also host several other services
for friends and family while I’m at it? Why shouldn’t I make the entire setup reproducable?</p>
<p>Here are some of the services I wanted to self-host:
- Web server: obviously, who doesn’t want a website?
- Some git server: having my own place to show off all the things I’ve done is certainly really cool.
- Wireguard: Free VPN along with the website? sign me up.
- CI/CD: automatic testing and releases of my software is cool, and also incredibly useful because that’s
how I plan to handle the website as well.</p>
<p>Of course, there are always more things I could be self-hosting. So it makes sense to automate
the setup, and that’s where podman comes in.</p>
<h2id="basics-of-podman">Basics of podman</h2>
<p>Before we can get to the exciting stuff, we need to go over what podman is, and how to
use it. Essentially, podman is a container engine: it lets you build and run applications in
a containerized environment. Containers are useful because they provide security,
easy setup and most importantly, reproducability.</p>
<p>I’m not going to spend any more time explaining what containers are and why they’re
good, that’s been done to death already. Right now, what matters is the actual setup,
so let’s get on with it.</p>
<p>If you’ve used docker before, you’ll feel right at home. Many commands are unchanged
from docker, making podman a suitable drop-in replacement. Some things like network
setups tend to be a little different, but that won’t matter too much right now.</p>
<p>In case you’re unfamiliar with docker, here are some basic commands:</p>
<divclass="highlight"><pretabindex="0"style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><codeclass="language-sh"data-lang="sh"><spanstyle="display:flex;"><span><spanstyle="color:#75715e"># Search for container images (on docker.io unless you configure otherwise)</span>
</span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"># run a container.</span>
</span></span><spanstyle="display:flex;"><span>$ podman run <image name>
</span></span><spanstyle="display:flex;"><span>
</span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"># run a container, but with a LOT of flags. I just listed the most useful ones.</span>
</span></span><spanstyle="display:flex;"><span>$ podman run
</span></span><spanstyle="display:flex;"><span> -i <spanstyle="color:#75715e"># interactive, so you can e.g. run a shell in the container</span>
</span></span><spanstyle="display:flex;"><span> -t <spanstyle="color:#75715e"># allocates a tty. useful with -i so that shell completion etc. can work</span>
</span></span><spanstyle="display:flex;"><span> -d <spanstyle="color:#75715e"># opposite of -i, detach and run in the background</span>
</span></span><spanstyle="display:flex;"><span> --port <HOST PORT>:<CONTAINER PORT><spanstyle="color:#75715e"># port forwarding, for when you need a server.</span>
</span></span><spanstyle="display:flex;"><span> -v <HOST DIR>:<CONT DIR>:<FLAGS><spanstyle="color:#75715e"># give the container access to some directory</span>
</span></span><spanstyle="display:flex;"><span><command><spanstyle="color:#75715e"># ... want a shell?</span>
</span></span><spanstyle="display:flex;"><span>
</span></span><spanstyle="display:flex;"><span><spanstyle="color:#75715e"># list running containers. add -a to list ALL containers, running or stopped.</span>
Published with <aclass="hover:underline hover:decoration-indigo-500 hover:text-indigo-500"href="https://gohugo.io"target="_blank"rel="noopener noreferrer">Hugo</a>&<aclass="hover:underline hover:decoration-indigo-500 hover:text-indigo-500"href="https://github.com/chrede88/qubt"target="_blank"rel="noopener noreferrer">Qubt</a>