Custom LXC Container Templates in Proxmox 5.0

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:

  1. Create a new container using the whichever distro you prefer. I went with Ubuntu 16.04
  2. Start that container
  3. SSH into that container (or you can SSH into Proxmox and use the command pct enter <container ID> to access your new container)
  4. 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.
  5. Verify everything you need is working with this container.
  6. Exit your container and shut it down.
  7. In the Proxmox web GUI under Server View, select your container and navigate to Backup
  8. Create a new backup but be sure to select GZIP compression
  9. After your backup finishes, open a terminal to your Proxmox environment (not the container)
  10. Find the backup you just made under /var/lib/vz/dump/<backup-name>.tar.gz and copy it to /var/lib/vz/template/cache/<new-backup-name>.tar.gz

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.

Dylan Hildenbrand

ETH: 0xf9aa91a96bd04f037cb95a4158a8bdda5a921525

profile for Dylan Hildenbrand on Stack Exchange, a network of free, community-driven Q&A sites

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.