You are currently viewing Docker Tutorial: From Basics to Cloud Integration

Docker has revolutionized the way developers build, ship, and run applications. In this tutorial, we’ll go through why Docker is importanthow to install it on Windowsworking 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

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:

ShellScript
docker --version

You should see something like:

ShellScript
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:18nginxmysql).
  • Container: A running instance of an image.

Example:

ShellScript
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

ShellScript
docker pull mysql:8

List Images

ShellScript
docker images

Run a Container

ShellScript
docker run -d --name mydb -e MYSQL_ROOT_PASSWORD=secret -p 3306:3306 mysql:8

List Running Containers

ShellScript
docker ps

Stop/Remove Containers

ShellScript
docker stop mydb
docker rm mydb

6. Dockerfile Basics

You can create your own images by writing a Dockerfile.

Example – Node.js App:

ShellScript
FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "server.js"]

Build & run:

ShellScript
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:

ShellScript
aws --version

Step 2: Configure AWS CLI

ShellScript
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)

  1. Create Repository
ShellScript
aws ecr create-repository --repository-name mydockerapp
  1. Authenticate Docker to AWS
ShellScript
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
  1. Tag and Push Image
ShellScript
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.
Please follow and like us:

Leave a Reply