Getting Started with Docker

A practical introduction for developers

Sarah Johnson | DevOps Conference 2025 | December 15, 2025

What We’ll Cover

  • Understanding containers and why they matter
  • Installing and setting up Docker
  • Creating your first container
  • Best practices for Docker in development

Why Docker Matters

Modern software development faces complexity challenges:

  • Problem: “It works on my machine” syndrome
  • Impact: Wasted time debugging environment differences
  • Solution: Containers provide consistent, portable environments

Docker makes development predictable and deployment reliable.

What is a Container?

A lightweight, standalone package that includes:

  • Application code
  • Runtime environment
  • System libraries
  • Dependencies
  • Configuration files

Think of it as: A shipping container for your software!

Virtual Machines vs Containers

Virtual Machines

  • Full OS per application
  • Gigabytes in size
  • Minutes to start
  • Higher resource usage
  • Complete isolation

Containers

  • Shared OS kernel
  • Megabytes in size
  • Seconds to start
  • Efficient resource use
  • Process-level isolation

Installing Docker

Docker Desktop is available for all platforms:

  1. Download from docker.com/get-started
  2. Run the installer
  3. Verify installation:
docker --version
# Output: Docker version 24.0.0

docker run hello-world
# Pulls and runs a test container

Your First Container

Let’s run a simple web server:

# Pull the nginx image
docker pull nginx:latest

# Run the container
docker run -d -p 8080:80 --name my-web-server nginx

# Check it's running
docker ps

# Visit http://localhost:8080 in your browser

Understanding Docker Images

An image is a template for creating containers:

  • Base images: nginx, python, node, ubuntu
  • Custom images: Built with Dockerfile
  • Layers: Images are built in efficient layers
  • Registries: Docker Hub stores public images
# Search for images
docker search python

# List local images
docker images

Creating a Dockerfile

Build custom images with a Dockerfile:

# Start from a base image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Copy application files
COPY . .

# Install dependencies
RUN pip install -r requirements.txt

# Define the command to run
CMD ["python", "app.py"]

Building Your Image

# Build the image
docker build -t my-python-app:1.0 .

# The -t flag tags your image with a name and version
# The . specifies the build context (current directory)

# Run your custom container
docker run -d -p 5000:5000 my-python-app:1.0

Essential Docker Commands

Command Purpose Example
docker ps List running containers docker ps -a (all)
docker stop Stop a container docker stop my-web-server
docker rm Remove a container docker rm my-web-server
docker logs View container logs docker logs my-web-server
docker exec Run command in container docker exec -it my-web-server bash

Docker Compose

For multi-container applications

Define your entire stack in docker-compose.yml

Start everything with one command

docker-compose up

Docker Compose Example

version: '3.8'

services:
  web:
    build: .
    ports:
      - "5000:5000"
    depends_on:
      - db

  db:
    image: postgres:15
    environment:
      POSTGRES_PASSWORD: secretpassword
    volumes:
      - db-data:/var/lib/postgresql/data

volumes:
  db-data:

Best Practices

  1. Use official base images - More secure and maintained
  2. Keep images small - Use alpine variants when possible
  3. Don’t run as root - Create user in Dockerfile
  4. Use .dockerignore - Exclude unnecessary files
  5. Tag your images - Use meaningful version tags

Development Workflow

# 1. Write your Dockerfile
vim Dockerfile

# 2. Build your image
docker build -t myapp:dev .

# 3. Run and test
docker run -p 8080:8080 myapp:dev

# 4. Make changes, rebuild
# Docker caches layers for speed!

# 5. Push to registry when ready
docker push myregistry.com/myapp:1.0

Common Pitfalls to Avoid

  • ❌ Not using volumes for persistent data
  • ❌ Exposing sensitive data in images
  • ❌ Running unnecessary services in containers
  • ❌ Not cleaning up unused images and containers
  • ❌ Hardcoding configuration (use env vars!)

Key Takeaways

  1. Containers solve real problems - Consistent environments across development and production
  2. Docker is approachable - Start with simple containers, grow into complex orchestration
  3. Best practices matter - Security, efficiency, and maintainability from day one

Resources

Thank You

Questions?

Sarah Johnson
sarah.johnson@example.com
@sarahjdev on Twitter
https://github.com/sarahjohnson