SmartDocs
Current page as Markdown (.md) Includes verification proof.
Partially verified · 1 of 3 code blocks verified
Verified as of 22 Jun 2026 · images:debian/13 Jump to verified block →

Installing Docker from the Official Script on Debian/Ubuntu

This guide walks you through installing the latest stable version of Docker Engine using the official convenience script provided by Docker, and then adding your user to the docker group so you can run Docker commands without sudo.

Warning
The official convenience script is designed for testing and development environments. It installs dependencies, adds Docker’s GPG key and repository, configures the Docker daemon, and starts the service. Review the script before running it. For production systems, use the repository-based installation method instead.

Prerequisites

  • A Debian- or Ubuntu-based distribution (e.g., Ubuntu 20.04+, Debian 11+).
  • A user account with sudo privileges.
  • Internet access.

Step 1 – Download and Run the Docker Installation Script

  1. Open a terminal.

  2. Download the script using curl or wget:

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

    or

    bash
    wget -qO get-docker.sh https://get.docker.com
    
  3. (Optional) Review the script contents:

    bash
    less get-docker.sh
    
  4. Run the script with sudo:

    bash
    sudo sh get-docker.sh
    

    The script will:

    • Detect your distribution and version.
    • Add Docker’s official APT repository.
    • Install Docker Engine, CLI, containerd, and Docker Compose (v2 plugin).
    • Start and enable the Docker service.
  5. Once the script finishes, verify that Docker is installed and running:

    bash
    sudo docker version
    sudo docker info
    

    These commands should display version information and system details.

Step 2 – Add Your User to the Docker Group

By default, docker commands require sudo. To allow your user to run Docker without sudo, add your user to the docker group.

  1. Add your user to the docker group:

    bash
    sudo usermod -aG docker $USER
    

    Replace $USER with your actual username if needed; $USER automatically expands to your current username.

  2. Apply the group change. You must log out and back in for the change to take effect. Alternatively, use one of the following methods to avoid logging out:

    • Method A – Start a new shell session with the group already applied (temporary):

      bash
      newgrp docker
      
    • Method B – Run su - $USER to start a fresh login session.

    Note: If you are using a desktop environment, the simplest way is to log out and log back in.

  3. Verify that you can run Docker commands without sudo:

    bash
    docker run hello-world
    

    If everything is set up correctly, you will see a welcome message from Docker.

Step 3 – (Optional) Manage Docker as a Non-Root User

After adding your user to the docker group, you can run all docker commands without sudo. However, be aware of the security implications: users in the docker group have effective root access. Only add trusted users to this group.

To check which users belong to the docker group:

bash
getent group docker

Step 4 – Clean Up (Optional)

The downloaded script file can be removed:

bash
rm get-docker.sh

Troubleshooting

  • “Permission denied” when running docker commands – Ensure your user is in the docker group and you have started a new session after the group modification.

  • Script fails with “unsupported distribution” – The official script only supports certain versions of Debian and Ubuntu. Check Docker’s documentation for supported distributions.

  • Docker service not running – Start it manually:

    bash
    sudo systemctl start docker
    sudo systemctl enable docker
    

Uninstalling Docker

If you ever need to remove Docker installed via the script, see the official uninstallation guide for Debian/Ubuntu.


bash
apt-get update
apt-get install -y curl
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
usermod -aG docker root
Proven
Environment: images:debian/13 · container
Success signal: exit 0
Verified: 22 Jun 2026
✓ Matches the published text
This proof supports the code shown above.

Summary

  • Use curl -fsSL https://get.docker.com | sudo sh to install Docker from the official script.
  • Add your user to the docker group with sudo usermod -aG docker $USER.
  • Log out and back in (or use newgrp docker) to apply group membership.
  • Verify with docker run hello-world.

This method gives you a quick Docker setup on Debian/Ubuntu. For production environments, consider the repository-based installation to have more control over updates and dependencies.