Docker Community Forums

Share and learn in the Docker community.

Best practise: migrating multiple VMs and VHosts to Docker

I currently have about 20 sites and applications hosted in AWS EC2. Some have their own EC2, whilst others share an EC2 with multiple virtual hosts on that EC2.

Each site is completely separate and unrelated from another. The ones which share an EC2 are generally much smaller with little traffic/resource requirement (hence the shared server).

I also have one EC2 server which is simply used to run batch and scheduled tasks alongside the live version of the site, to ensure the live site stays accessible even when the scheduled tasks are heavy.

I am looking to making use of Docker across my whole dev > prod environment for better use of server resources, and easier migrations between environments etc.

I’m keen to get your thoughts on the best practise for production server hardware.

Is it best to use one larger EC2 and have every site as its own docker container on there? This sounds like less server admin, a tidier overall setup, and from what I understand, each docker container still keeps itself to itself from a security point of view. But, any server issues or resource spikes would impact all sites (mitigated by a load balancer).

Or, am I best to keep them split across multiple EC2s, i.e. on EC2 per docker container? This seems completely against the point of docker, but not sure if I’m missing something.

Using a single EC2 for all sites then makes it easier (less admin) to set up load balancers and/or fall over servers too, but adds admin to serve totally different domains to different sites all within the same host.

Note; if it makes any difference, I use RDS for MySQL; no MySQl running on any EC2s directly.

Thanks in advance

In a production setup you want to set ressource constraints for each container. The sum of the the ressource constraints will indicate what type of machine you need.
Typicaly you would want to aim for multiple nodes, rather than a single node spof setup. One EC2 instance per container kind of beats the benefit of containers.

In earlier projects I used EKS clusters with autoscalling groups, which due to the ressource constraints knew when to scale the number of cluster nodes up or down.

In my current projects the setup is simple enough to leverage ECS Fargate. My impression is that an ECS Service behaves like a Docker Swarm service.

True for EKS and ECS:
– you don’t need to maintainer the EC2 instance yourself
– access to RDS is no problem

1 Like