Skip to content

lxc containers on aws ec2

0

We have use case where we would like to run our custom lxc container images on top of ec2 instances, typically we rent dedicated servers from various hosting companies where we order additional IPs and assign those IPs to lxc containers running on top of those machines by configuring existing host interface into bridge mode.

When attempting to run containers on EC2, we encountered an issue: while outbound traffic works as expected, inbound traffic is blocked. This has made it challenging to replicate our setup on EC2.

Has anyone successfully run LXC containers on EC2 instances with inbound traffic enabled? Any insights, recommendations, or guidance would be greatly appreciated!

asked 2 years ago449 views

3 Answers
1

While AWS does not directly support or provide managed services for LXC containers, it is possible to run LXC containers on EC2 instances. However, the networking setup you're accustomed to with dedicated servers requires some adjustments when working with EC2.

The issue you're experiencing with inbound traffic being blocked is likely due to EC2's default security settings and networking configuration. To enable inbound traffic to your LXC containers on EC2, you'll need to make several configuration changes:

  1. Security Group Configuration: Ensure that the EC2 instance's security group allows inbound traffic on the required ports for your LXC containers.

  2. Network Interface Configuration: EC2 instances typically use ENIs (Elastic Network Interfaces) for networking. You may need to configure additional ENIs and assign them to your LXC containers.

  3. VPC and Subnet Settings: Make sure your VPC and subnet configurations allow for the traffic patterns you need.

  4. Elastic IPs: Instead of ordering additional IPs as you would with dedicated servers, you can use Elastic IPs in AWS to assign static public IP addresses to your containers.

  5. Bridge Mode Configuration: You can still set up bridge mode on your EC2 instance, but you'll need to ensure it's properly configured to work with AWS networking.

To achieve a setup similar to your dedicated server environment, you might consider using the EC2 instance in bridge network mode and then configuring your LXC containers to use this bridge. This would involve:

  1. Creating a bridge interface on the EC2 host.
  2. Configuring the EC2 instance's primary network interface to use this bridge.
  3. Setting up your LXC containers to use the bridge for networking.
  4. Associating Elastic IPs with your containers through the EC2 instance.

Keep in mind that this setup is more complex in AWS than with traditional dedicated servers and requires careful configuration to ensure security and proper networking. You may need to work closely with AWS support or consult with an AWS networking specialist to fine-tune your configuration.

Alternatively, you might want to consider using AWS's native container services like ECS or EKS, which are designed to work seamlessly with AWS networking and provide easier management of containerized workloads. While these use Docker containers rather than LXC, they might offer a more streamlined solution for running containers on AWS infrastructure.
Sources
Containers services on AWS - Containers on AWS
Networking - Containers on AWS
Containers on AWS - Containers on AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

1

The above answer, specifically the security groups should allow you to enable inbound traffic.

In addition to the options for multiple ENIs and EIPs, you could use and ALB (Application Load Balancer) to direct ingress to various ports on the same host without multiple ENIs and EIPs.

Hope this helps.

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Is there any migration or any tool available to convert lxc images to AMIs?

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.