How to Create a Custom Ubuntu Server Image?
Asked by
CuriousCat42
I'm looking to create a custom Ubuntu Server image but I'm struggling to find a comprehensive guide. Canonical doesn't seem to have a complete resource for this. I've come across several discussions about setting up an autoinstall file for cloud-init, but I'm unsure how to implement all the changes I need. My goals include adding a Docker repository, installing Docker CE directly on the image, ensuring the install runs without prompts, rebooting once completed, including a custom Docker image, applying all current updates, specifying a unique location for SSH keys that's neither GitHub nor Launchpad, and modifying the grub.conf in the final image. I'm also sharing this on another forum, but I don't want it to get buried under beginner questions.
Answers
Have you considered creating a template? Start with a full installation, customize it to your liking, and then use something like virt-sysprep. This way, you can launch the template without conflicts. I still recommend incorporating cloud-init for networking and initial install updates.
Reply to this answer
If you want complete customization, I recommend Cubic. It allows you to modify any Ubuntu ISO quite extensively. You can check it out at the GitHub link I provided.
Reply to this answer
From what I've seen, it's often best to keep customization of the image minimal. In my setup, I use cloud-init to add my Ansible user (with sudo access), install OpenSSH, lldpd, and the puppet agent. After that, everything else is managed by my central config management system, like Ansible or Puppet. Cloud-init is useful but has a specific order to its operations that can't be changed, which sometimes causes issues if you try to overcomplicate it. If you already have a config management tool, it can handle things like Docker installation much more smoothly.
Reply to this answer
You might want to look into using Packer for your needs. Itโs designed for creating machine images across various platforms and might simplify your workflow.
Reply to this answer
Fifteen years ago, I used debootstrap in a chroot environment for creating Xen images. More recently, Iโve transitioned to using Packer, but not sure if that's the best current method.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions