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.
5 Answers
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.
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.
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.
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.
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.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures