I'm looking to set up Docker on my EC2 instance with Ubuntu and want to ensure it's optimized and secure. I've managed to create an Ubuntu instance and install Docker using apt, but I'm curious if there are better practices or guidelines for this setup. I've checked the Amazon Marketplace for Docker AMIs to see if there are any pre-optimized solutions, but the options are limited and come with hourly fees. Can anyone share tips for creating the ideal Docker environment on Ubuntu or recommend a suitable AMI?
1 Answer
I suggest blocking SSH completely by shutting down port 22 and using SSM sessions instead. Only keep essential ports open, like 80 and 443, in your EC2 security group. Installing Docker on Ubuntu is pretty straightforward after that. Just keep in mind that if you want to run in production, you’ll need to think about SSL, load balancing, and more advanced setups. If you're open to it, looking into ECS Fargate might also be worthwhile, although it's a bit more complex.
The advantage of EC2 is that you can use a t2.micro instance for free for a year under the free tier!