Overview
Docker Desktop for Linux provides a complete Docker development environment with a graphical user interface, Kubernetes integration, and advanced features like Docker Scout and Docker Extensions. This guide covers both Docker Engine installation using the convenience script and Docker Desktop setup on Ubuntu.
Docker Desktop vs Docker Engine: Docker Desktop runs containers inside a lightweight VM and includes additional tools like Docker Compose, Docker Build, and a GUI. Docker Engine is the core runtime that can run standalone. Both can be installed side-by-side on the same machine.
Prerequisites
Before installing Docker, ensure your system meets the following requirements:
| Requirement | Minimum | Recommended |
|---|---|---|
| Ubuntu Version | 22.04 LTS (Jammy) | 24.04 LTS (Noble) |
| CPU Architecture | x86_64 (64-bit) | x86_64 or ARM64 |
| RAM | 4 GB | 8 GB or more |
| Disk Space | 20 GB | 50 GB+ for images |
| Kernel | 5.4+ | Latest stable |
| Virtualization | KVM support | KVM enabled in BIOS |
Remove Conflicting Packages
Before installing Docker, remove any unofficial or conflicting packages that might interfere with the installation:
1sudo apt remove docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc 2>/dev/null || trueImportant: Images, containers, volumes, and networks stored in
/var/lib/docker/ are preserved when uninstalling Docker packages. If you
want a fresh installation, remove these directories after uninstalling
conflicting packages.
Install Docker Engine
Update and install required packages
1sudo apt update && \2sudo apt install -y apt-transport-https ca-certificates curl software-properties-commonThese packages provide essential functionality for secure package management:
- apt-transport-https — Enables APT to download packages over HTTPS
- ca-certificates — Provides root certificates for SSL/TLS verification
- curl — Command-line tool for transferring data with URLs
- software-properties-common — Provides scripts for managing software repositories
Install Using Convenience Script
1curl -fsSL https://get.docker.com -o get-docker.sh2
3sudo sh ./get-docker.shConvenience Script Details: The get.docker.com script automatically
detects your Linux distribution, configures the package repository, and
installs the latest stable Docker Engine, CLI, containerd, Docker Compose
plugin, and Docker Buildx plugin.
What the convenience script installs:
docker-ce— Docker Engine daemondocker-ce-cli— Docker command-line interfacecontainerd.io— Container runtimedocker-buildx-plugin— Docker Build with BuildKit featuresdocker-compose-plugin— Docker Compose v2
Preview Script Actions (Dry Run)
Before running the installation script, you can preview what it will do:
1sudo sh ./get-docker.sh --dry-runVerify Docker Installation
After installation, verify Docker is running correctly:
1sudo docker version2sudo docker run hello-worldPost-Installation: Non-Root User Access
By default, Docker commands require sudo privileges. To run Docker as a non-root user, add your user to the docker group:
1sudo usermod -aG docker $USER2newgrp dockerSecurity Note: Adding users to the docker group grants privileges
equivalent to root access. Only add trusted users to this group.
Verify non-root access works:
1docker run hello-worldRootless Mode Installation
Rootless mode runs the Docker daemon and containers without root privileges, providing enhanced security. This is ideal for multi-user environments or when root access is restricted.
1dockerd-rootless-setuptool.sh install2
3export PATH=/usr/bin:$PATH4export DOCKER_HOST=unix:///run/user/1000/docker.sockUnderstanding Rootless Mode
| Feature | Rootful Docker | Rootless Docker |
|---|---|---|
| Daemon runs as | root | Non-root user |
| Container UID mapping | Direct (0 = root) | User namespace remapped |
| Socket location | /var/run/docker.sock | $XDG_RUNTIME_DIR/docker.sock |
| Network capabilities | Full (iptables, bridge) | Limited (slirp4netns/vpnkit) |
| Port binding | Any port | Ports > 1024 by default |
Make Rootless Mode Persistent
Add these environment variables to your shell profile (~/.bashrc or ~/.zshrc):
1echo 'export PATH=/usr/bin:$PATH' >> ~/.bashrc2echo 'export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock' >> ~/.bashrc3source ~/.bashrcEnable Rootless Docker as Systemd User Service
1systemctl --user enable docker2systemctl --user start dockerTo ensure the service starts at boot (even without user login):
1sudo loginctl enable-linger $USERInstall Docker Desktop
From Official Docker Desktop Download
Install Prerequisites for Docker Desktop
Before installing Docker Desktop, install the required dependencies:
1sudo apt install -y gnome-terminal pass uidmap dbus-user-sessionInstall the .deb Package
After downloading the .deb file:
1sudo apt install ./docker-desktop-<version>-amd64.debLaunch Docker Desktop
1systemctl --user start docker-desktopOr launch from the applications menu.
Sign in to Docker Desktop
Docker Desktop uses GPG and pass for secure credential storage on Linux.
Generate GPG Key
1gpg --generate-key2
3### init pub key4
5pass init #your pub keyNow you can sign in Docker Desktop
GPG Key Generation Details
When running gpg --generate-key, you'll be prompted for:
- Real name — Your full name for the key identity
- Email address — Associated email for the key
- Passphrase — Secure passphrase to protect the private key
After generation, note the public key ID (a 40-character hex string or the last 16 characters). Use this ID to initialize the password store.
Verify Credential Store
1pass lsThis should show an empty password store, ready for Docker Desktop to store your credentials securely.
Managing Docker Service
Check Docker Service Status
1sudo systemctl status dockerStart, Stop, and Restart Docker
1# Start Docker2sudo systemctl start docker3
4# Stop Docker5sudo systemctl stop docker6
7# Restart Docker8sudo systemctl restart docker9
10# Enable Docker to start on boot11sudo systemctl enable dockerDocker Configuration
Configure Docker Daemon
Docker daemon configuration is stored in /etc/docker/daemon.json. Common configurations include:
1{2 "storage-driver": "overlay2",3 "log-driver": "json-file",4 "log-opts": {5 "max-size": "10m",6 "max-file": "3"7 },8 "default-address-pools": [{ "base": "172.17.0.0/16", "size": 24 }],9 "live-restore": true10}After modifying the configuration, restart Docker:
1sudo systemctl restart dockerRootless Mode Configuration
For rootless mode, the configuration file is located at:
~/.config/docker/daemon.json
Switching Docker Contexts
When both Docker Engine and Docker Desktop are installed, use contexts to switch between them:
1# List available contexts2docker context ls3
4# Switch to Docker Desktop5docker context use desktop-linux6
7# Switch to Docker Engine8docker context use defaultTroubleshooting
Common Issues and Solutions
| Issue | Solution |
|---|---|
| Permission denied on socket | Add user to docker group: sudo usermod -aG docker $USER |
| Docker daemon not running | Start service: sudo systemctl start docker |
| Cannot connect to Docker Desktop | Ensure VM is running: systemctl --user status docker-desktop |
| Slow file sharing (Linux) | Check subuid/subgid configuration |
| GPG key errors on sign-in | Re-initialize pass: pass init <gpg-key-id> |
Check Docker Logs
1# Docker Engine logs2sudo journalctl -u docker.service3
4# Docker Desktop logs (user service)5journalctl --user -u docker-desktopVerify KVM Support (for Docker Desktop)
Docker Desktop requires KVM for virtualization. Verify KVM is available:
1kvm-ok2# Or3ls -la /dev/kvmIf KVM is not accessible, add your user to the kvm group:
1sudo usermod -aG kvm $USERUninstall Docker
Uninstall Docker Engine
1sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras2sudo rm -rf /var/lib/docker3sudo rm -rf /var/lib/containerdUninstall Docker Desktop
1sudo apt remove docker-desktop2rm -rf ~/.docker/desktop3sudo rm /usr/local/bin/com.docker.cliQuick Reference
| Command | Description |
|---|---|
docker version | Show Docker version info |
docker info | Display system-wide information |
docker ps | List running containers |
docker ps -a | List all containers |
docker images | List images |
docker pull <image> | Download an image |
docker run <image> | Run a container |
docker stop <container> | Stop a running container |
docker rm <container> | Remove a container |
docker rmi <image> | Remove an image |
docker system prune | Remove unused data |