1 Hour Guide1 Hour Guide
Remaining:60 min
Back to Tutorials
💻 Code60 minIntermediateMay 2, 2026

1 Hour to Docker Basics

Containerize an app in 60 minutes. From installing Docker to running your own container and publishing an image to Docker Hub.

#docker#containers#devops#deployment

By the end of this hour, you'll run a real app in a container and understand the core Docker workflow. No prior DevOps knowledge needed.

🎯 What You'll Build

A containerized web app + Docker Hub image:

docker build -t myapp:1.0 .
docker run -p 8080:8080 myapp:1.0
# Visit http://localhost:8080

⏱️ Time Breakdown

010min
Install Docker
1025min
Your first container
2540min
Write a Dockerfile
4055min
Build & run your image
5560min
Push to Docker Hub

📋 Prerequisites

  • Basic command line
  • A Docker Hub account

Step 1: Install Docker (0–10 min)

Mac/Windows: Download Docker Desktop

Ubuntu/Debian:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Log out and back in

Check:

docker --version
docker run hello-world

Checkpoint

hello-world should run and print "Hello from Docker!".

Step 2: Your First Container (10–25 min)

Run an Nginx container:

docker run -d -p 8080:80 --name my-nginx nginx

What this does:

  • -d → run in background (detached)
  • -p 8080:80 → map host port 8080 to container port 80
  • --name my-nginx → give it a name
  • nginx → use the official Nginx image

Visit http://localhost:8080

Manage containers:

docker ps              # Running containers
docker ps -a           # All containers (including stopped)
docker stop my-nginx   # Stop it
docker start my-nginx  # Start again
docker rm my-nginx     # Delete

Interactive shell:

docker run -it --rm ubuntu bash
# Now you're inside an Ubuntu container!

Checkpoint

Run docker ps and see your Nginx container. Then stop and remove it.

Step 3: Write a Dockerfile (25–40 min)

Create a simple Node.js app:

mkdir my-docker-app && cd my-docker-app
cat > package.json << EOF
{
  "name": "my-docker-app",
  "version": "1.0.0",
  "main": "server.js",
  "scripts": {"start": "node server.js"},
  "dependencies": {"express": "^4.18.0"}
}
EOF

cat > server.js << 'EOF'
const express = require('express');
const app = express();
const PORT = 8080;

app.get('/', (req, res) => {
  res.send('Hello from Docker! 🐳');
});

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});
EOF

Create Dockerfile:

# Use Node.js 20 Alpine (lightweight)
FROM node:20-alpine

# Set working directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy app code
COPY . .

# Expose port
EXPOSE 8080

# Run the app
CMD ["npm", "start"]

Checkpoint

You should have Dockerfile, package.json, and server.js.

Step 4: Build & Run (40–55 min)

Build the image:

docker build -t myapp:1.0 .

What this does:

  • -t myapp:1.0 → tag with name and version
  • . → build context is current directory

Run it:

docker run -d -p 8080:8080 --name myapp myapp:1.0

Visit http://localhost:8080

View logs:

docker logs myapp
docker logs -f myapp  # Follow (tail -f style)

Inspect container:

docker inspect myapp

Stop and remove:

docker stop myapp
docker rm myapp

Checkpoint

Your app is running in a container! Check logs and see the server started message.

Step 5: Push to Docker Hub (55–60 min)

Login:

docker login
# Enter your Docker Hub credentials

Tag and push:

docker tag myapp:1.0 YOURUSERNAME/myapp:1.0
docker push YOURUSERNAME/myapp:1.0

Now anyone can run it:

docker run -d -p 8080:8080 YOURUSERNAME/myapp:1.0

🎉 You just published a Docker image!

🎁 Bonus

Multi-stage build (smaller final image):

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Run stage
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY package*.json ./
RUN npm ci --production
CMD ["npm", "start"]

Docker Compose (run multi-container apps):

version: '3.8'
services:
  web:
    build: .
    ports:
      - "8080:8080"
  redis:
    image: redis:alpine

Run:

docker-compose up

📚 Next Steps

1 Hour to Deploy Your First Site
Get your first website live on the internet in 60 minutes. Free, with HTTPS, auto-deploys on git push.
60 min
1 Hour to Git Basics
Master Git in 60 minutes. From zero to branches, merges, and pushing to GitHub — the commands you actually need.
60 min

🔗 Resources