Running containers in the cloud doesn’t have to be complicated. In this guide, we’ll walk through creating an AWS EC2 Linux instance, installing Docker, and setting up Portainer to manage containers visually and effortlessly.
By the end, you’ll have a lightweight, production-ready Docker host you can control from your browser.
Prerequisites
Before we begin, make sure you have:
- An AWS account
- Basic familiarity with Linux and SSH
- An EC2 key pair for secure access
- A local machine with SSH installed
Step 1: Launch an AWS EC2 Linux Instance
- Log in to the AWS Management Console
- Navigate to EC2 → Launch Instance
- Choose an AMI:
- Select Amazon Linux 2 (recommended for stability and AWS compatibility)
- Choose an instance type:
- t2.micro or t3.micro (free tier eligible)
- Configure key settings:
- Attach your key pair
- Allow SSH (port 22) in the security group
- Add port 9000 (Portainer UI) and port 80 if you plan to run web apps
- Launch the instance 🚀
Once running, copy the public IPv4 address.
Step 2: Connect to the EC2 Instance
From your local terminal:
ssh -i your-key.pem ec2-user@<EC2_PUBLIC_IP>
If successful, you’ll be logged into your Amazon Linux server.
Step 3: Install Docker on Amazon Linux
Update the system:
sudo yum update -y
Install Docker:
sudo amazon-linux-extras install docker -y
Start and enable Docker:
sudo systemctl start docker
sudo systemctl enable docker
(Optional) Allow your user to run Docker without sudo:
sudo usermod -aG docker ec2-user
exit
Reconnect to apply the changes.
Verify installation:
docker --version
Step 4: Run Docker Containers
Test Docker by running a container:
docker run hello-world
If you see the success message, Docker is working correctly 🎉
Step 5: Install Portainer
Portainer gives you a clean web UI to manage containers, images, networks, and volumes.
Create a Docker volume for Portainer
docker volume create portainer_data
Run Portainer
docker run -d \
-p 9000:9000 \
--name portainer \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce
Check that it’s running:
docker ps
Step 6: Access the Portainer Dashboard
Open your browser and go to:
http://<EC2_PUBLIC_IP>:9000
On first launch:
- Create an admin password
- Select Docker (local) as the environment
- Click Connect
You now have full visual control over your Docker host 🎯
What You Can Do with Portainer
With Portainer, you can:
- Deploy containers using forms or Docker Compose
- Monitor container health and logs
- Manage volumes, networks, and images
- Stop, start, or scale services
- Secure access with user roles
It’s perfect for:
- Small production workloads
- Learning Docker visually
- Managing remote servers with ease
Security Best Practices
Before using this in production, consider:
- Restricting port 9000 to your IP only
- Enabling HTTPS with a reverse proxy
- Using IAM roles instead of access keys
- Regularly updating Docker and the OS
Conclusion
By combining AWS EC2, Amazon Linux, Docker, and Portainer, you get a powerful yet simple container platform that scales with your needs. Whether you’re deploying side projects or learning container orchestration, this setup is an excellent foundation.
Happy containerizing 🐳🚀
