SynfraCore
Synfracore
Start Learning
Navigation

Academies

Platform

RoadmapsLabsCertificationsInterviewPYQsAI AssistantCareer
Start Learning Free🗺️ Learning Roadmaps
Blog/Docker

Docker for Beginners: From Zero to Your First Container in 30 Minutes

SynfraCore·January 2025·8 min read

What is Docker and Why Does It Matter?

Docker packages applications into containers — lightweight, portable units that include everything the app needs: code, runtime, and libraries. The problem it solves: 'It works on my machine.' Containers run identically everywhere.

Install Docker

macOS / Windows: Download Docker Desktop from docker.com. It includes everything.

Ubuntu/Linux:

bash
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
docker run hello-world

Your First Container

bash
docker run -d -p 8080:80 --name my-nginx nginx
# Visit http://localhost:8080
docker ps
docker logs my-nginx
docker stop my-nginx && docker rm my-nginx

Build Your Own Image

Create a file called Dockerfile:

dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "app.py"]
bash
docker build -t my-app:v1 .
docker run -d -p 8000:8000 my-app:v1

Docker Compose for Multi-Container Apps

yaml
version: "3.8"
services:
  web:
    build: .
    ports: ["8000:8000"]
    depends_on: [db]
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_PASSWORD: secret
    volumes: [db-data:/var/lib/postgresql/data]
volumes:
  db-data:
bash
docker compose up -d
docker compose logs -f
docker compose down

Essential Commands

bash
docker ps                 # Running containers
docker ps -a              # All containers
docker images             # List images
docker exec -it myapp sh  # Shell into container
docker logs myapp         # View logs
docker stats              # Live resource usage
docker system prune       # Clean up unused resources

What Next?

Go to the Docker Intermediate section to learn multi-stage builds, networking, and production security patterns.

Found this useful? Share it:

Twitter / X LinkedIn WhatsApp Telegram

Weekly DevOps & Cloud digest

Every Sunday — tutorials, interview questions, tips, and what changed in DevOps and Cloud this week.

Join our Community
Daily tips, job alerts, interview help — join engineers learning together
← All articlesStart Learning Docker