Custom LXC Container Templates in Proxmox 5.0

in #linux7 years ago

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 development 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.

If you like this post, give it an upvote or resteem! If you want more posts like this, let me know. Find more content like this at closingtags.com.

Sort:  

Congratulations @pennywise! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @pennywise! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!