Complete Docker Tutorial with GUI Examples (Docker Desktop Focused)

Table of Contents

1. What is Docker?

Docker is an open-source platform that uses OS-level virtualization to deliver software in packages called **containers**. Containers are lightweight, standalone, executable packages of software that include everything needed to run an application: code, runtime, system tools, system libraries, and settings.

The primary benefit of Docker is its ability to provide a consistent environment across different computing environments (development, testing, production). This helps eliminate "it works on my machine" problems and streamlines the entire software development lifecycle.

Key Docker Concepts:

2. Docker Desktop Installation

Docker Desktop is an easy-to-install application for Windows, macOS, and Linux that provides a straightforward GUI to manage your containers, applications, and images directly from your machine. It includes the Docker Engine, Docker CLI, Docker Compose, Kubernetes (optional), and other helpful tools.

A. System Requirements:

B. Installation Steps:

  1. Download Docker Desktop: Go to the official Docker Desktop download page: docs.docker.com/desktop/install/. Download the installer for your operating system.
  2. Run the Installer:
    • Windows: Double-click the `.exe` installer. Follow the wizard. Ensure "Install required Windows components for WSL 2" (or "WSL 2 backend" is enabled). A restart might be required.
    • macOS: Double-click the `.dmg` file and drag the Docker icon to your Applications folder. Open Docker from Applications.
    • Linux: Follow distribution-specific instructions (e.g., download `.deb` or `.rpm` and install via package manager, then run `systemctl start docker`).
  3. Initial Setup & Login:
    • After installation, launch Docker Desktop. It might take a moment to start the Docker Engine.
    • You'll typically be prompted to log in to Docker Hub (optional, but recommended for pulling/pushing images).
    • Docker Desktop will show a tutorial or a dashboard indicating it's running.
  4. Verify Installation (CLI): Open your terminal/command prompt and run:
    docker --version
    docker compose version
    docker run hello-world # This pulls and runs a simple container to confirm functionality

3. Docker Desktop UI Overview

The Docker Desktop application provides a user-friendly graphical interface to manage various Docker components.

Access: Launch the Docker Desktop application from your applications menu (Windows Start Menu, macOS Applications folder, Linux App Launcher).

Key Sections of Docker Desktop GUI:

4. Core Concepts Explained for GUI Users

Let's delve into the fundamental Docker concepts with a focus on how they appear and are managed in Docker Desktop.

A. Images (Blueprints)

An image is a read-only template with instructions for creating a Docker container. It packages the application code, a runtime (like Node.js or Python), libraries, environment variables, and configuration files.

B. Containers (Running Instances)

A container is a running instance of an image. You can start, stop, pause, restart, and delete containers.

5. Managing Containers (GUI)

The **Containers** tab in Docker Desktop provides a central place to control your running applications.

  1. List Containers: The main view shows:
    • Name: The container's name.
    • Status: `Running`, `Exited`, `Paused`.
    • Ports: Mapped ports (e.g., `8080 > 80`).
    • Image: The image the container was created from.
  2. Start/Stop/Restart/Pause/Delete:
    • Hover over a container. Buttons for **Start**, **Stop**, **Restart**, **Pause**, **Delete** will appear.
    • Click the corresponding button.
    • Deleting a container removes its writable layer, but the image remains.
  3. View Details (Click on Container Name):
    • Logs: View real-time logs from the container's standard output.
    • Inspect: See detailed JSON configuration (network, volumes, environment variables).
    • Stats: Monitor CPU, Memory, Disk I/O, Network I/O in real-time.
    • Files: Browse the container's filesystem. (Very useful for debugging!).
    • Terminal: Open a shell directly inside the running container (e.g., `/bin/bash` or `/bin/sh`).
    • # Equivalent CLI for terminal access:
      docker exec -it my-nginx-instance bash # or sh

6. Managing Images (GUI)

The **Images** tab allows you to manage the templates for your containers.

  1. List Images: Shows downloaded and built images with their size, creation date, and tags.
  2. Run Image: Click the **Run** button next to an image to create a new container from it.
  3. Delete Image: Select an image and click the **Delete** (trash can) icon.
    • You cannot delete an image if it's currently used by a running or stopped container. You must delete the container first.
    # Equivalent CLI:
    docker rmi my-custom-nginx-app # Removes the image
  4. Build Image: (As seen in section 4A, this is typically done via CLI using a `Dockerfile`).
  5. Push Image: Push your local image to Docker Hub (after logging in).
    • Hover over a local image. Click the **Push to Hub** button.
    • You might need to tag the image with your Docker Hub username first:
      docker tag my-custom-nginx-app:latest your_dockerhub_username/my-custom-nginx-app:latest
    • Then push from CLI or GUI.
    # Equivalent CLI:
    docker push your_dockerhub_username/my-custom-nginx-app:latest

7. Managing Volumes (GUI)

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. They allow data to outlive the container's lifecycle.

8. Managing Networks (GUI)

Docker networks allow containers to communicate with each other and with the host machine. By default, Docker creates a `bridge` network.

9. Docker Compose (GUI & CLI)

Docker Compose is a tool for defining and running multi-container Docker applications. You define your application's services, networks, and volumes in a `compose.yaml` (or `docker-compose.yml`) file, then use a single command to bring up the entire application stack.

Docker Desktop integrates Docker Compose, allowing you to manage Compose-defined applications from the UI.

A. Example `compose.yaml` (Simple Web App with Database):

Create a directory (e.g., `my-compose-app`) and place the following files:

# compose.yaml
version: '3.8' # Specify Compose file format version

services:
  web:
    build: . # Build Dockerfile in current directory for this service
    ports:
      - "8000:80" # Map host port 8000 to container port 80
    volumes:
      - ./nginx-html:/usr/share/nginx/html # Mount local 'nginx-html' dir to Nginx web root
    depends_on:
      - db # Ensure 'db' service starts before 'web'
    networks:
      - app-network

  db:
    image: postgres:15-alpine # Use a PostgreSQL image
    environment:
      POSTGRES_DB: mydatabase
      POSTGRES_USER: myuser
      POSTGRES_PASSWORD: mypassword
    volumes:
      - db_data:/var/lib/postgresql/data # Persistent volume for database data
    networks:
      - app-network

volumes: # Define named volumes for persistence
  db_data:

networks: # Define custom bridge network
  app-network:
    driver: bridge
# nginx-html/index.html (create 'nginx-html' directory first, then this file inside it)
<!DOCTYPE html>
<html>
<head>
    <title>Docker Compose App</title>
</head>
<body>
    <h1>Hello from Docker Compose!</h1>
    <p>This is a multi-service application.</p>
    <p>Web service talks to a PostgreSQL database.</p>
</body>
</html>
# Dockerfile (for the 'web' service, create in 'my-compose-app' root)
FROM nginx:latest
COPY nginx-html/ /usr/share/nginx/html/ # Copy local html to container
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

B. Running Docker Compose (CLI - from `my-compose-app` directory):

docker compose up -d # Builds, creates, starts, and runs services in detached mode

You can then access the web app at `http://localhost:8000`.

C. Managing Docker Compose Applications (GUI):

D. Stopping and Cleaning Up Compose App (CLI):

docker compose down # Stops and removes containers, networks, and default volumes
# If you created named volumes (like 'db_data'), you might need to remove them explicitly:
docker volume rm my-compose-app_db_data # The volume name is usually prefixed with project name

10. Docker Hub & Registries (GUI)

Docker Hub is the world's largest container image registry. Docker Desktop integrates directly with it.

A. Connecting to Docker Hub:

B. Exploring Docker Hub (in Docker Desktop):

C. Managing Your Repositories (in Docker Desktop):

11. Docker Extensions

Docker Extensions enhance Docker Desktop's functionality, providing new capabilities like security scanning, Kubernetes dashboards, cloud integrations, and more, all within the Docker Desktop UI.

Access: Click **Extensions** in the left sidebar of Docker Desktop.

Popular examples include: Disk Usage, Resource Monitor, Vulnerability Scan (Snyk), Kubernetes Dashboard.

12. Docker Desktop Settings & Resources

The **Settings** menu (gear icon in the top right) allows extensive configuration.

13. Troubleshooting Docker Desktop

When things don't work as expected, Docker Desktop provides several diagnostic tools.

Access: Click the **Troubleshoot** icon (bug icon) in the top right of Docker Desktop.

14. Best Practices with Docker Desktop

Docker Desktop: Your Gateway to Containerization!

Docker Desktop simplifies the complex world of containerization, providing a powerful yet accessible platform for developers. By leveraging its intuitive GUI alongside the command line for deeper control, you can efficiently build, run, and manage containerized applications, streamlining your development workflow and ensuring consistency across environments. Happy containerizing!