If you’re at all into homelabbing, are a server administrator, or have an interest virtualization, you’ve probably heard of Proxmox. In my case, I just love to tinker with my homelab. One of the things I love about Proxmox, is how quickly I can get a containerized server up and running. All I need to do is open the web interface, click ‘Create CT’, fill out a couple of fields, and it’s done. It takes less than a minute to get an entirely new server on my network. The downside? I have to reinstall various services like Apache/nginx, PHP, and MySQL/MariaDB every time I spin up a new container. Now, I know what you’re thinking:
Couldn’t you just use a turnkey template provided by Proxmox with everything pre-installed?
And you’re right, I could do that but I want to have complete control over these containers. I want to know everything that’s installed them. So what’s next best option?
Create one container with everything that I regularly need, and use that as a template. It sounds intimidating, but it’s so ridiculously simple that I’m concerned with how short this blog post will be. Here’s what you do:
- Create a new container using the whichever distro you prefer. I went with Ubuntu 16.04
- Start that container
- SSH into that container (or you can SSH into Proxmox and use the command
pct enter <container ID>to access your new container)
- Install all of the services that you need. Things like nginx, PHP 7, MariaDB, Git, and the Let’s Encrypt Certbot could be useful for web dev projects.
- Verify everything you need is working with this container.
- Exit your container and shut it down.
- In the Proxmox web GUI under Server View, select your container and navigate to Backup
- Create a new backup but be sure to select GZIP compression
- After your backup finishes, open a terminal to your Proxmox environment (not the container)
- Find the backup you just made under
/var/lib/vz/dump/<backup-name>.tar.gzand copy it to
You’ve just created a new LXC template for use with your Proxmox 5.0 environment. Now anytime you want to spin up another container, you can just select that as your template! Also, the container that you previously created is still valid so feel free to use that as well.