Tools: Docker in 30 Minutes: From Install to First Container (2026)

Tools: Docker in 30 Minutes: From Install to First Container (2026)

Docker in 30 Minutes: From Install to First Container

What Problem Does Docker Solve?

Installation

Core Concepts

Your First Container

Visit http://localhost:8080 — you'll see the nginx welcome page!

What's running?

Stop it

Remove it

Writing a Dockerfile

Dockerfile

requirements.txt

Build and run

Essential Commands

Docker Compose (Multi-Container Apps)

Docker vs VM Docker lets you package your application with everything it needs into a lightweight container that runs anywhere. No more "it works on my machine." Let's get you from zero to a running container in 30 minutes. Before Docker: you install Python 3.11, your teammate uses 3.10, the server runs 3.9. Your app uses PostgreSQL 15, but production is on 14. Dependency hell. Docker wraps your app AND its exact environment into one portable unit — a container. Download Docker Desktop from docker.com. It includes Docker Engine, CLI, Docker Compose, and a GUI dashboard. Verify: Create a simple Python app: @app.route('/')

def home(): return 'Hello from Docker!' if name == 'main': app.run(host='0.0.0.0', port=5000) FROM python:3.12-slim # start from a Python imageWORKDIR /app # set working directoryCOPY requirements.txt . # copy dependency listRUN pip install -r requirements.txtCOPY . . # copy everything elseEXPOSE 5000 # document what port we useCMD ["python", "app.py"] # what to run on start docker build -t my-python-app .docker run -d -p 5000:5000 my-python-app docker compose up -d # start everything

docker compose down # stop everything Containers share the host OS kernel, so they start in milliseconds and use minimal RAM. VMs each need their own OS, taking gigabytes. For most web apps, Docker is the clear winner. See also: Python Tutorial: From Zero to Your First Program, DevOps for Developers: CI/CD, Docker, IaC, and Monitoring — A Practical Guide, Kubernetes vs Docker Swarm vs Nomad (2026): Container Orchestration Compared. Read the full article on AI Study Room for complete code examples, comparison tables, and related resources. Found this useful? Check out more developer guides and tool comparisons on AI Study Room. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 500;">docker --version -weight: 500;">docker run hello-world # should print a welcome message -weight: 500;">docker --version -weight: 500;">docker run hello-world # should print a welcome message -weight: 500;">docker --version -weight: 500;">docker run hello-world # should print a welcome message # Run nginx web server in a container -weight: 500;">docker run -d -p 8080:80 --name my-nginx nginx Visit http://localhost:8080 — you'll see the nginx welcome page! What's running? -weight: 500;">docker ps Stop it -weight: 500;">docker -weight: 500;">stop my-nginx Remove it -weight: 500;">docker rm my-nginx # Run nginx web server in a container -weight: 500;">docker run -d -p 8080:80 --name my-nginx nginx Visit http://localhost:8080 — you'll see the nginx welcome page! What's running? -weight: 500;">docker ps Stop it -weight: 500;">docker -weight: 500;">stop my-nginx Remove it -weight: 500;">docker rm my-nginx # Run nginx web server in a container -weight: 500;">docker run -d -p 8080:80 --name my-nginx nginx Visit http://localhost:8080 — you'll see the nginx welcome page! What's running? -weight: 500;">docker ps Stop it -weight: 500;">docker -weight: 500;">stop my-nginx Remove it -weight: 500;">docker rm my-nginx # app.py from flask import Flask app = Flask(name) @app.route('/') def home(): return 'Hello from Docker!' if name == 'main': app.run(host='0.0.0.0', port=5000) Dockerfile FROM python:3.12-slim # -weight: 500;">start from a Python image WORKDIR /app # set working directory COPY requirements.txt . # copy dependency list RUN -weight: 500;">pip -weight: 500;">install -r requirements.txt COPY . . # copy everything else EXPOSE 5000 # document what port we use CMD ["python", "app.py"] # what to run on -weight: 500;">start requirements.txt flask==3.1.0 Build and run -weight: 500;">docker build -t my-python-app . -weight: 500;">docker run -d -p 5000:5000 my-python-app # app.py from flask import Flask app = Flask(name) @app.route('/') def home(): return 'Hello from Docker!' if name == 'main': app.run(host='0.0.0.0', port=5000) Dockerfile FROM python:3.12-slim # -weight: 500;">start from a Python image WORKDIR /app # set working directory COPY requirements.txt . # copy dependency list RUN -weight: 500;">pip -weight: 500;">install -r requirements.txt COPY . . # copy everything else EXPOSE 5000 # document what port we use CMD ["python", "app.py"] # what to run on -weight: 500;">start requirements.txt flask==3.1.0 Build and run -weight: 500;">docker build -t my-python-app . -weight: 500;">docker run -d -p 5000:5000 my-python-app # app.py from flask import Flask app = Flask(name) @app.route('/') def home(): return 'Hello from Docker!' if name == 'main': app.run(host='0.0.0.0', port=5000) Dockerfile FROM python:3.12-slim # -weight: 500;">start from a Python image WORKDIR /app # set working directory COPY requirements.txt . # copy dependency list RUN -weight: 500;">pip -weight: 500;">install -r requirements.txt COPY . . # copy everything else EXPOSE 5000 # document what port we use CMD ["python", "app.py"] # what to run on -weight: 500;">start requirements.txt flask==3.1.0 Build and run -weight: 500;">docker build -t my-python-app . -weight: 500;">docker run -d -p 5000:5000 my-python-app -weight: 500;">docker ps # list running containers -weight: 500;">docker ps -a # list ALL containers -weight: 500;">docker images # list images -weight: 500;">docker logs <container> # view logs -weight: 500;">docker exec -it <c> bash # shell into a running container -weight: 500;">docker rm <container> # -weight: 500;">remove a container -weight: 500;">docker rmi <image> # -weight: 500;">remove an image -weight: 500;">docker system prune -a # clean up everything unused -weight: 500;">docker ps # list running containers -weight: 500;">docker ps -a # list ALL containers -weight: 500;">docker images # list images -weight: 500;">docker logs <container> # view logs -weight: 500;">docker exec -it <c> bash # shell into a running container -weight: 500;">docker rm <container> # -weight: 500;">remove a container -weight: 500;">docker rmi <image> # -weight: 500;">remove an image -weight: 500;">docker system prune -a # clean up everything unused -weight: 500;">docker ps # list running containers -weight: 500;">docker ps -a # list ALL containers -weight: 500;">docker images # list images -weight: 500;">docker logs <container> # view logs -weight: 500;">docker exec -it <c> bash # shell into a running container -weight: 500;">docker rm <container> # -weight: 500;">remove a container -weight: 500;">docker rmi <image> # -weight: 500;">remove an image -weight: 500;">docker system prune -a # clean up everything unused # -weight: 500;">docker-compose.yml version: '3.8' services: web: build: . ports: - "5000:5000" depends_on: - db db: image: postgres:16 environment: POSTGRES_PASSWORD: secret volumes: - pgdata:/var/lib/postgresql/data volumes: pgdata: -weight: 500;">docker compose up -d # -weight: 500;">start everything -weight: 500;">docker compose down # -weight: 500;">stop everything # -weight: 500;">docker-compose.yml version: '3.8' services: web: build: . ports: - "5000:5000" depends_on: - db db: image: postgres:16 environment: POSTGRES_PASSWORD: secret volumes: - pgdata:/var/lib/postgresql/data volumes: pgdata: -weight: 500;">docker compose up -d # -weight: 500;">start everything -weight: 500;">docker compose down # -weight: 500;">stop everything # -weight: 500;">docker-compose.yml version: '3.8' services: web: build: . ports: - "5000:5000" depends_on: - db db: image: postgres:16 environment: POSTGRES_PASSWORD: secret volumes: - pgdata:/var/lib/postgresql/data volumes: pgdata: -weight: 500;">docker compose up -d # -weight: 500;">start everything -weight: 500;">docker compose down # -weight: 500;">stop everything