Skip to content

Docker installation

Sara Wattanasombat edited this page Aug 13, 2024 · 1 revision

This page will guide you through a simple Docker installation. Please make sure that you have administrative privileges on your device before installing.

Windows installation

Pre-requisite

Prior to installing the Docker desktop, make sure you’ve installed and enabled Windows Sub-system for Linux version 2 (WSL2) as it is needed to run a Linux-based container on a Windows machine.

  1. On your search bar, look for “Windows PowerShell” right click and choose “Run as administrator”

  2. Install WSL2 by entering the command wsl --install

    wsl --install

    This command will enable the features necessary to run WSL and install the Ubuntu distribution of Linux. Follow the prompt to create Ubuntu user.

  3. Restart your machine

  4. After restart, open Windows PowerShell again and check the installation by entering the command.

    wsl -l -v
    # NAME                   STATE           VERSION
    # Ubuntu                 Running         2

    If You see Ubuntu is installed with WSL version 2, you can proceed to install Docker Desktop.

Install Docker Desktop

  1. Download the installer from https://docs.docker.com/desktop/install/windows-install/.

Note

In most cases, if you’re using Intel or AMD CPU, choose the x86_64 version. Otherwise if you’re using an Arm CPU i.e. Snapdragon, please use Arm (Beta) version.

  1. Double-click Docker Desktop Installer.exe to run the installer.
  2. Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
  3. Start the Docker Desktop by searching for Docker and select Docker Desktop in the search results.
  4. Accept the terms and conditions
  5. Docker Desktop starts after you accept the terms.

MacOS installation

Install Docker Desktop

  1. Download the installer from https://docs.docker.com/desktop/install/mac-install/ using the download buttons. Make sure you have the right version according to your device’s processor (Apple silicon or Intel chip).
  2. Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder.
  3. Double-click Docker.app in the Applications folder to start Docker.
  4. Accept the terms and conditions
  5. From the installation window, select “Use recommended settings” (Requires password). This lets Docker Desktop automatically set the necessary configuration settings.
  6. Select Finish.

Linux installation

Install using the convenience script

Docker provides a convenience script at https://get.docker.com/ to install Docker into development environments non-interactively.

Supported distributions

  • Ubuntu
  • Debian
  • Fedora
  • Red Hat Enterprise Linux

Note

Before installing, make yourself familiar with potential risks and limitations of the convenience script:

  • The script requires root or sudo privileges to run.
  • The script attempts to detect your Linux distribution and version and configure your package management system for you.
  • The script doesn't allow you to customize most installation parameters.
  • The script installs dependencies and recommendations without asking for confirmation.
  • By default, the script installs the latest stable release of Docker.
  • The script isn't designed to upgrade an existing Docker installation.

Learn more

To install with convenience script, open the terminal and run the following commands:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Post-installation for Linux

These optional post-installation procedures are optional but will help to configure your Linux host machine to work better with Docker.

Manage Docker as a non-root user

By default only the root user can access the Docker as it requires administrative privileges to run, other users can only access it using sudo.

If you don't want to preface the docker command with sudo, create a Unix group called docker and add users to it.

To create the docker group and add your user:

  1. Create the docker group.

    sudo groupadd docker

    Note: On some Linux distributions, the system automatically creates this group.

  2. Add your user to the docker group.

    sudo usermod -aG docker $USER
  3. Log out and log back in so that your group membership is re-evaluated.

  4. Verify that you can run docker commands without sudo.

    docker run hello-world