Docker has revolutionized the way developers build, ship, and run applications. In this tutorial, we’ll go through why Docker is important, how to install it on Windows, working with images and containers, and how to operate Docker from both its GUI and CLI. Finally, we’ll integrate Docker with AWS for deployment.
1. Why Do We Need Docker?
Traditionally, running an application meant dealing with different OS environments, dependencies, and “works on my machine” issues. Docker solves this by packaging applications and their dependencies into containers—lightweight, portable environments that run the same way anywhere.
Key benefits:
- Consistency across development, testing, and production.
- Easy to scale and deploy.
- Works with any language or stack.
- Portable across local machines, on-premises, and the cloud.
2. Installing Docker on Windows
Step 1: Download Docker Desktop
- Go to Docker Desktop for Windows
- Download the Windows Installer (choose Windows with WSL 2 backend if possible).
Step 2: Install
- Run the installer and follow the steps.
- Enable WSL 2 integration during installation if prompted.
Step 3: Verify Installation Open Command Prompt or PowerShell and run:
docker --version
You should see something like:
Docker version 27.0.1, build abc123
3. Understanding Images and Containers
- Image: A read-only template with instructions to create a container (e.g.,
node:18
,nginx
,mysql
). - Container: A running instance of an image.
Example:
docker pull nginx
docker run -d -p 8080:80 nginx
- Pulls the nginx image.
- Runs it in detached mode (
-d
) on port 8080.
Visit: http://localhost:8080 → You’ll see the Nginx welcome page.
4. Operating Docker via GUI (Docker Desktop)
Main Tabs:
- Containers/Apps → List of running and stopped containers. Start/Stop/Delete them with buttons.
- Images → Local images on your system. You can pull new ones or remove old ones.
- Volumes → Persistent storage for containers.
5. Operating Docker via CLI
Pull an Image
docker pull mysql:8
List Images
docker images
Run a Container
docker run -d --name mydb -e MYSQL_ROOT_PASSWORD=secret -p 3306:3306 mysql:8
List Running Containers
docker ps
Stop/Remove Containers
docker stop mydb
docker rm mydb
6. Dockerfile Basics
You can create your own images by writing a Dockerfile
.
Example – Node.js App:
FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "server.js"]
Build & run:
docker build -t mynodeapp .
docker run -p 3000:3000 mynodeapp
7. Integrating Docker with AWS
Step 1: Install AWS CLI
Download: https://aws.amazon.com/cli/
Verify:
aws --version
Step 2: Configure AWS CLI
aws configure
Provide:
- AWS Access Key ID
- AWS Secret Access Key
- Region (e.g.,
us-east-1
)
Step 3: Push Image to Amazon ECR (Elastic Container Registry)
- Create Repository
aws ecr create-repository --repository-name mydockerapp
- Authenticate Docker to AWS
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
- Tag and Push Image
docker tag mynodeapp:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/mydockerapp:latest
docker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/mydockerapp:latest
Step 4: Deploy to AWS ECS
- Create an ECS Cluster in AWS Console.
- Define a Task Definition using the pushed image.
- Run the service and your containerized app will be live in AWS.
8. Summary
- Docker simplifies application deployment by using containers.
- You can work via Docker Desktop GUI or CLI.
- Images are the blueprint; containers are the running apps.
- Integration with AWS ECR makes cloud deployment seamless.