Skip to content
PotatoScript edited this page Feb 16, 2025 · 2 revisions

Docker Setup Tutorial

Prerequisites

Before you begin, ensure you meet the following requirements:

  • Operating System: Windows, macOS, or Linux.
  • Admin/Root Access: You need admin privileges to install Docker.
  • Hardware Requirements:
    • At least 4GB of RAM.
    • Sufficient disk space to download Docker images and containers.

Step 1: Download Docker

  1. Visit the official Docker website.
  2. Download the installer for your operating system:
    • Windows: Docker Desktop for Windows.
    • macOS: Docker Desktop for macOS.
    • Linux: Install Docker Engine via your package manager (detailed below).

Step 2: Install Docker

For Windows:

  1. Double-click the downloaded Docker Desktop installer.
  2. Follow the installation wizard:
    • Accept the license agreement.
    • Enable "Use WSL 2-based engine" (recommended for better performance).
  3. After installation, restart your system if prompted.
  4. Launch Docker Desktop and sign in with your Docker Hub account (create one if you don’t have it).

For macOS:

  1. Open the .dmg file you downloaded.
  2. Drag the Docker icon to your Applications folder.
  3. Launch Docker from Applications and complete the setup wizard.
  4. Sign in with your Docker Hub account.

For Linux:

  1. Update your package manager:
    sudo apt update && sudo apt upgrade
  2. Install required packages:
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
  3. Add Docker’s official GPG key:
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  4. Add the Docker repository:
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  5. Install Docker Engine:
    sudo apt update
    sudo apt install docker-ce docker-ce-cli containerd.io
  6. Start and enable Docker:
    sudo systemctl start docker
    sudo systemctl enable docker

Step 3: Verify Installation

  1. Open a terminal or command prompt.
  2. Run the following command to verify Docker is installed correctly:
    docker --version
    Example output: Docker version 20.10.12, build e91ed57.
  3. Run the Docker "Hello World" container:
    docker run hello-world
    This will pull the hello-world image from Docker Hub and run it, verifying that Docker is working correctly.

Step 4: Configure Docker (Optional)

  • Set Up WSL 2 on Windows (if not already done):
    1. Install WSL 2:
      wsl --install
    2. Set WSL 2 as the default engine in Docker Desktop settings.
  • Manage Docker as a Non-Root User (Linux Only):
    1. Create a Docker group:
      sudo groupadd docker
    2. Add your user to the Docker group:
      sudo usermod -aG docker $USER
    3. Log out and log back in to apply the changes.

Step 5: Docker Hub Login

To push and pull images to/from Docker Hub:

  1. Log in to Docker from the terminal:
    docker login
  2. Enter your Docker Hub username and password.

Step 6: Update Docker (Optional)

To ensure Docker is up to date:

  • On Windows/macOS: Docker Desktop will prompt for updates.
  • On Linux:
    sudo apt update && sudo apt upgrade docker-ce

Step 7: Test Docker Commands

Try running these basic commands:

  1. List running containers:
    docker ps
  2. List all containers:
    docker ps -a
  3. Pull an image from Docker Hub:
    docker pull ubuntu:latest
  4. Run a container:
    docker run -it ubuntu bash

Troubleshooting

  • Permission Denied (Linux): Ensure your user is added to the docker group.
  • Service Not Starting: Restart the Docker service:
    sudo systemctl restart docker
  • Network Issues: Check your firewall or VPN settings.

With Docker set up and running, you're ready to start building and managing containers! 🎉

  • A kernel manages applications and hardware resources
  • Window share the Linux kernel so window can run Linus application container
  • Install Docker https://docs.docker.com/get-docker/
  • Work-Flow
    • Add Dockerfile which is a plain instruction to pack the application into an image
    • Image contain everything that the application need to run
    • Load the Image into a container for processing and let us run our application on local machine
    • we can also push the Image into the Registry or Docker-Hub which is the storage of Image so that everyone can use
    • other can pull the Image from the Docker-Hub to run or use the application (as the same way as our development machine)

Clone this wiki locally