You open your project at home on your Mac. Everything breaks. You SSH into the office server running Windows and something else breaks. Your teammate on Linux has a completely different problem. The code is the same. The environment is not. That mismatch alone has killed more deployment timelines than bad code ever will.
Docker fixes that. It packages your application and everything it needs into a single container that runs identically on any machine. In this tutorial, Alston walks through the exact steps to create a Docker image on an AWS EC2 instance, from launching the server to seeing “Hello World” load in a browser via a running container. If you are building toward AWS ECS, this is the foundation. Follow along and you will have a working Docker setup before the end of the video.
What You’ll Walk Out With
- A plain-English understanding of what Docker is and what containerization actually means
- A live EC2 instance on Amazon Linux, configured with the right security groups and key pair
- Docker installed and running on that instance, with the EC2 user added to the Docker group
- A Dockerfile created from scratch and built into a working Docker image
- A Hello World web application running inside a container and accessible at your EC2 public IP
- The core Docker commands you will use again and again: docker build, docker run, docker info, and docker images
- A clear next step into AWS ECS, and a tool to find the right online income path for your skill set at finder.platformproof.com
What Docker Actually Is
Docker describes itself as the world’s leading software containerization platform. That phrase sounds corporate until you understand what containerization means in practice.
Containerization is the process of packaging software into standardized units for development, shipment, and deployment. Think of a shipping container on a cargo ship. It does not matter whether the ship is sailing to Japan or Germany. The container holds everything inside it, and it loads and unloads the same way at every port. Docker does the same thing for software. Your application and all its dependencies go inside the container. That container behaves identically whether it runs on Windows, Mac, or Linux.
More specifically, Docker lets you build, run, test, and deploy distributed applications that are based on Linux containers. The “distributed” part matters if you are working with microservices or cloud architecture, but even for solo developers the value is clear. You stop saying “it works on my machine” because the machine is no longer the variable.
Alston lays out the scenario from his own work life. At work, Windows systems. At home, Mac or Linux. That gap in operating systems creates friction. Files behave differently. Commands differ. Environment variables get misconfigured. Docker removes that friction by making the software environment portable. If you work on a team where developers use different operating systems, Docker is not optional, it is the baseline that makes collaboration possible at any real scale.
In this tutorial, Docker is used as the foundation for AWS ECS (Elastic Container Service). You are not going deep on Docker itself here. You are learning just enough Docker to see what ECS is actually managing when you use it. That is the scope, and it is the right scope for this point in the course.
What You Need Before You Start
Before you launch anything, make sure these three things are in place.
An AWS account with EC2 access. You need to be logged in as the root user or as a user who has full access to EC2. If you are not the root user, the simplest path is to have your administrator grant you Administrator Access. At minimum, you need EC2 permissions. If you already completed an earlier EC2 section in this course, you have them. If you jumped straight to this section, get those permissions sorted first.
An existing key pair (.pem file). The tutorial assumes you already created a key pair in a previous lesson. Alston uses his key pair from the Canada Central region. The reason you want to reuse an existing key pair rather than create a new one is simple: it saves time, and you already know where the .pem file lives on your machine. Make sure you are in the same AWS region where your key pair exists before you launch anything.
Command line access. This tutorial is heavy on terminal commands. Alston flags this clearly at the start. If you are not comfortable with the command line, or if you do not have it set up on your machine, pause and get that sorted before continuing. You will be using SSH to connect to your EC2 instance, and then running a series of commands inside that instance. None of them are complicated, but you do need a terminal.
Step 1: Launch Your EC2 Instance
Start at the AWS Management Console. Go to EC2 under the Compute section. Before you do anything else, confirm you are in the correct region. Alston is in Canada Central because that is where his key pair lives. Match your region to your existing key pair.
Click Launch Instance. For the Amazon Machine Image, select the Amazon Linux AMI at the top of the list. This is the default option and the one the tutorial is built around. For the instance type, select t2.micro. It is free-tier eligible and more than sufficient for this exercise.
On the configuration page, leave the VPC and subnet settings at their defaults. Make sure Auto-assign Public IP is enabled. You need a public IP to access the Hello World app from your browser later. Leave storage at the default setting. It is adequate for this tutorial.
Add a tag if you want to keep things organized. Alston tags his instance as Type: Docker EC2 so it is easy to identify later in the console. This is optional but useful when you have multiple instances running.
Under security groups, you need at minimum port 22 open for SSH access. Alston selects an existing security group that already has ports 22, 80, and 443 open. If your security group does not have those ports, add them now. Port 22 is essential. Port 80 is what the Hello World app will be served on. AWS will show a warning that the instance is open to the world. For this short tutorial, that is acceptable. Do not leave it open permanently once you are done.
Click Review and Launch, then Launch. When prompted for a key pair, choose your existing one, acknowledge that you have access to it, and click Launch Instances. The instance will take a few minutes to spin up. Pause here and wait until it shows as running in the EC2 console before moving on.
Step 2: SSH Into Your EC2 Instance
Once your instance is running, find your public IP address in the EC2 console. You will also need the name of your .pem key pair file.
Open your terminal and go to the folder where your .pem file is stored. Alston’s is in a folder called ssh1 inside his Downloads directory. Use cd to get there. Then run the SSH command:
ssh ec2-user@YOUR_PUBLIC_IP -i YOUR_KEY_NAME.pem
Replace YOUR_PUBLIC_IP with the actual IP from the console, and YOUR_KEY_NAME with the name of your .pem file. When you first connect, SSH will ask if you want to continue connecting. Type yes and press enter. You will see a fingerprint warning. That is expected.
Once connected, your terminal prompt changes to show something like ec2-user@ip-xxx-xxx-xxx-xxx and you will see the Amazon Linux AMI banner. That banner means you are successfully inside your EC2 instance. Everything from here happens inside this remote machine, not on your local computer.
Step 3: Update Your Machine and Install Docker
The first command to run on a fresh EC2 instance is always an update. Type:
sudo yum update -y
The -y flag tells the package manager to answer yes to any prompts automatically. Without it, you would have to confirm each update manually. Let this run until it finishes. Depending on how many packages need updating, it could take a minute or two.
Once the update is complete, install Docker. Alston installs the community edition. On Amazon Linux, the command is:
sudo amazon-linux-extras install docker -y
This installs Docker from the Amazon Linux Extras repository, which is the recommended method for this AMI. If you are on a newer Amazon Linux 2023 instance, the command differs slightly, but the tutorial is built around the standard Amazon Linux AMI shown in the video. Let the installation finish completely before moving on.
Now start the Docker service:
sudo service docker start
If Docker starts correctly, you will see a confirmation in the terminal output. Docker is now running on your EC2 instance, but you are not done yet. You still need to set up your user permissions correctly before the next steps will work.
Step 4: Add the EC2 User to the Docker Group
By default, Docker commands require root privileges. That means you would have to type sudo before every single Docker command. To avoid that, you add the EC2 user to the Docker group. Run this command:
sudo usermod -a -G docker ec2-user
Breaking that down: usermod modifies a user account. The -a flag appends the user to the group rather than replacing existing group memberships. The -G docker specifies the Docker group. And ec2-user is the user being modified.
After running this command, try verifying it worked:
docker info
If you get a “permission denied while trying to connect to the Docker daemon” error, that is completely normal. It happens because the group membership change requires a reboot to take effect. Do not worry. Go back to your EC2 console, select your instance, click Actions, then Instance State, then Reboot. Confirm the reboot. The instance will restart and your SSH session will disconnect.
Wait about 60 seconds, then SSH back in using the same command from Step 2. Run docker info again. This time you should see output showing the number of containers, images, server version, and other Docker metadata. That output confirms Docker is running correctly and your user has the right permissions.
Step 5: Create Your Dockerfile
A Dockerfile is a plain text file that contains the instructions Docker uses to build an image. Think of it as a recipe. You define the base operating system, what software to install, what files to copy in, and what command to run when the container starts. Docker reads those instructions and assembles the image layer by layer.
Create the file with this command:
touch Dockerfile
Run ls to confirm the file is there. You will see Dockerfile listed in the directory. Now open it for editing:
nano Dockerfile
This opens the nano text editor inside your terminal. For this tutorial, Alston adds the configuration for a simple Hello World web application. The exact content is available in the course resources. The key elements of a Hello World Dockerfile are a base image (such as Amazon Linux or a minimal web server), an instruction to expose a port, and a command to start the web server when the container runs.
After adding the content, press Control+X to exit nano. It will ask if you want to save. Press Y, then Enter to confirm the filename. Your Dockerfile is now saved and ready to build.
Step 6: Build Your Docker Image
With the Dockerfile in place, build the Docker image by running:
docker build -t hello-world .
The -t flag tags the image with a name, in this case hello-world. The period at the end tells Docker to look for the Dockerfile in the current directory. Docker reads through your Dockerfile instructions one by one, pulling the base image and layering your additions on top. This may take a minute or two the first time, since Docker has to pull base layers from the internet. Subsequent builds are faster because Docker caches the layers it has already downloaded.
Once the build finishes, verify the image was created:
docker images –filter reference=hello-world
You should see your hello-world image listed with its image ID, creation time, and size. That is confirmation that the build succeeded.
Step 7: Run the Container and Test It
Now run the image as a container:
docker run -p 80:8080 hello-world
The -p flag maps ports between your host and the container. Port 80 on the EC2 instance maps to port 8080 inside the container, which is where the Hello World app is listening. This is why you needed port 80 open in your security group back in Step 1.
Go back to your EC2 console. Find the public IP address for your instance. Copy it. Open a new browser tab and paste the IP address into the address bar. Hit enter. You should see the text Hello World on the page.
That page loading in your browser means the entire chain worked. EC2 instance running. Docker installed. Dockerfile built into an image. Container started. Port mapped correctly. Web server inside the container responding to requests from the outside world.
Alston puts it simply: “that is believe it or not, that’s it. You are now a Docker specialist. You can possibly add that to your resume.” He is being a little generous, but the point stands. You completed the full cycle from zero to a running containerized application on AWS.
What Comes After This: AWS ECS
This tutorial is specifically scoped to get you ready for ECS. Everything you just did, launching EC2, installing Docker, building and running an image, is exactly what ECS automates and scales for you. ECS (Elastic Container Service) is AWS’s managed service for running Docker containers in production. Instead of manually managing an EC2 instance, configuring Docker, and monitoring containers, ECS handles the orchestration layer for you.
The next step in the AWS demystified series is the ECS dashboard. You will see how the same Docker image you just built gets registered in ECS and used as the foundation for a scalable containerized application. Everything from this tutorial carries forward directly.
Not sure whether cloud skills, content, or consulting is the right path for your online income?
Answer 5 questions and get a match at finder.platformproof.com.
Honest Drawbacks to Know Before You Use Docker on EC2
Docker on EC2 is a great learning environment. It is not always the right production setup. Here is what to consider.
You are managing the instance yourself. When you run Docker directly on EC2, you are responsible for the underlying server. That means patching it, monitoring it, restarting it if it crashes, and scaling it manually if traffic spikes. ECS and EKS exist precisely because that manual management does not scale well.
Security groups need attention. The tutorial opens port 80 to the entire internet. For a quick demo that is fine. For anything real, you want to tighten that down. Use security group rules to restrict traffic to known IP ranges or to a load balancer rather than exposing your EC2 instance directly.
Rebooting disconnects you. The permission issue with the Docker group requires a reboot. That is a minor inconvenience in this tutorial, but in production, unexpected reboots mean downtime. Plan for it and use processes like ECS task definitions that restart containers automatically.
The 2018 context matters. This tutorial was recorded in 2018. The core Docker concepts and commands have not changed significantly. But AWS tooling has evolved. Amazon Linux 2 and Amazon Linux 2023 have different package management commands. Always check the current AWS documentation if the commands do not match what you see in your console.
t2.micro has limits. Free-tier eligible and great for learning, but t2.micro instances are CPU-burstable. For anything beyond a Hello World app, you will need a larger instance type or a proper container orchestration setup.
Find Your X
You just ran a containerized app on AWS. That is a concrete, real skill. Whether that skill points you toward cloud consulting, DevOps freelancing, course creation, or something else entirely depends on the rest of your background and what you actually want to build. Use finder.platformproof.com to match your specific situation to an online income path that fits. Five questions, a clear answer.
Frequently Asked Questions
Do I need to know Linux to follow this tutorial?
You need to be comfortable with basic terminal commands: navigating directories with cd, running commands, and using a simple text editor like nano. You do not need to be a Linux expert. The commands in this tutorial are straightforward. If you have never touched a terminal, spend 30 minutes on a beginner command line course first, then come back.
Why does Docker give a permission denied error after installation?
The Docker daemon runs as root by default. When you add the ec2-user to the Docker group, that change does not apply to your current session until the instance reboots. Reboot via the EC2 console (Actions > Instance State > Reboot), SSH back in, and the error goes away. This is expected behavior on Amazon Linux.
What is the difference between a Docker image and a Docker container?
An image is the blueprint. A container is a running instance of that blueprint. The image you build with docker build is static. When you run docker run, Docker takes that image and starts a container from it. You can run multiple containers from the same image simultaneously. Think of the image as a class and the container as an object, if that analogy helps.
Can I reuse the same .pem file for multiple EC2 instances?
Yes, within the same AWS region. A key pair is regional. Alston reuses his existing key pair specifically to save time and avoid creating a new one. If you want to launch an instance in a different region, you need a key pair that exists in that region, or you need to create one there.
What ports do I actually need open in my security group?
For this tutorial, you need port 22 (SSH, so you can connect to the instance) and port 80 (HTTP, so the Hello World app is accessible in a browser). Port 443 for HTTPS is good practice for any real application but is not required for the Hello World demo. Alston’s security group also has 443 open because he reused an existing group from earlier in the course.
How do I stop the running Docker container when I am done?
In the terminal where you ran docker run, press Control+C to stop the container. If you ran it in detached mode (with the -d flag), use docker ps to see running containers, then docker stop CONTAINER_ID to stop the specific one. For this tutorial, the container runs in the foreground, so Control+C is enough.
Is this setup production-ready?
No. This is a learning environment intentionally. The security group is open to the internet, there is no load balancer, no auto-scaling, no health checks, and no container restart policy. The purpose here is to understand what Docker does and how it runs on EC2, which is the groundwork for understanding ECS. Move to ECS for anything production-facing.
What is ECS and how does it relate to what I just built?
Amazon ECS (Elastic Container Service) is AWS’s managed container orchestration service. Instead of manually launching an EC2 instance, installing Docker, and running containers yourself, ECS handles all of that for you at scale. The Docker image you built in this tutorial is exactly what ECS uses to run your containers. ECS adds scheduling, auto-scaling, load balancing, and health management on top of what you just did manually. This tutorial is the manual version of what ECS automates.
Read Next
If you want to go deeper on the AWS command line tools you will use alongside Docker and EC2, the next natural step is getting the AWS CLI set up directly on an EC2 instance.
How to Install AWS CLI on an EC2 Instance (Step-by-Step Tutorial) walks through the installation and configuration process so you can manage AWS resources from inside your EC2 instance without switching back to the browser console.
Sources
- Alston Godbolt, “Creating a Docker Image on AWS EC2 (2018),” YouTube, https://youtu.be/VRWTtVreEM8
- Docker Documentation, “What is a Container?” docker.com
- AWS Documentation, “Amazon EC2 Instance Types,” aws.amazon.com
- AWS Documentation, “Install Docker on Amazon Linux 2,” aws.amazon.com
Related Reading
- How to Create Viral Faceless AI Videos (Step-by-Step Guide)
- How to Create an Email Address in Bluehost (Step-by-Step Guide)
- How I Use AI to Create Viral YouTube Thumbnails (Step-by-Step)
- How to Create and Sell Digital Products Online (Step-by-Step)
Helping 1 million working adults make their first $3,000 online with the skills they already have. Alston Godbolt, Platform Proof.