Can I lanuch an EC2 instance in AWS from an LXC instead of an AMI?

Say I create a container in my laptop with the desired combination of software and configurations.

Can I use it somehow to launch an EC2 instance in AWS, instead of using an AMI?

Or, can I create an AMI from an LXC?

LXD container’s don’t contain a kernel (they share the host’s) so its unlikely they would work as a VM AMI.

I suppose it would potentially be possible to convert a LXD VM image to an AMI, but I have no idea how one would do that.

You could run LXD on an AWS instance and then use lxc export and lxc import to copy a container from your laptop to the AWS instance.

1 Like

It is not a direct conversion but using packer is a good way to keep an LXC container and an AWS AMI configuration synced.

You will need to create scripts that set up your LXC, but if you can find a similar base image for the AMI, and if your scripts are portable, you can keep them in sync with packer.

1 Like