Introduction
1. What is Docker?
Docker lets you build, test, and deploy applications quickly.
- Docker is an open platform for developing, shipping, and running applications quickly.
- Docker packages software into standardized and isolated units called containers that have everything the software needs to run including libraries, system tools, code, and runtime.
- Quickly deploy and scale applications into any environment and know your code will run.
2. How Docker works
- Providing a standard way to run your code.
- An operating system for containers.
- Like how a virtual machine virtualizes server hardware, containers virtualize the operating system of a server with Docker Engine (Docker CE – docker daemon).
The difference between VM and Docker Container
More: Docker Overview
Installation
Windows installation
Note: We can also only install the Docker daemon which allows you to run Windows containers only. When you install the Docker daemon on Windows, the daemon does not contain Docker components such as buildx and compose. If you are running Windows 10 or 11, we recommend that you install Docker Desktop instead. If you still just want to install the Docker daemon, this is for you Install server and client binaries on Windows.
I. System requirements
There are two main methods to install Docker on Windows: using Windows Subsystem for Linux (WSL) backend or using Hyper-V backend.
a. WSL 2 backend (recommended)
- WSL version 1.1.3.0 or higher.
- Windows 11 64-bit: Home, Pro, Enterprise, or Education version 21H2 or higher.
- Windows 10 64-bit:
- Minimum: Home, Pro, Enterprise, or Education 21H2 (build 19044) or higher.
- Recommend: Home, Pro, Enterprise, or Education 22H2 (build 19045) or higher.
- WSL 2. [How to install](How to install)
- Hardware prerequisites:
- 64-bit processor with Second Level Address Translation (SLAT).
- At least 4GB system RAM.
- Enable hardware virtualization in BIOS. [Enable hardware virtualization](Enable hardware virtualization)
WSL 2 and Windows Home: Enable Virtual Machine Platform and WSL in Windows Features
Enable Hypervisor at Windows startup. Run as Administrator
More: WSL
b. Hyper-V backend and Windows Containers
- Windows 11 64-bit: Pro, Enterprise, or Education version 21H2 or higher.
- Windows 10 64-bit:
- Minimum: Home, Pro, Enterprise, or Education 21H2 (build 19044) or higher.
- Recommend: Home, Pro, Enterprise, or Education 22H2 (build 19045) or higher.
- Turn on Hyper-V and Containers Windows features.
- Hardware prerequisites:
- 64-bit processor with Second Level Address Translation (SLAT).
- At least 4GB system RAM.
- Turn on BIOS-level hardware virtualization support in the BIOS settings.
Verify Hardware Compatibility: Run systeminfo
command to check all required Hyper-V features
Check Hyper-V compatibility
Enable Hyper-V on Windows Pro or Enterprise
II. Install Docker Desktop on Windows
a. Install interactively
- i. Download the installer from the home page [Docker Desktop](Docker Desktop).
- ii. Run “Docker Desktop Installer.exe” and by default, Docker Desktop is installed at
"C:\Program Files\Docker\Docker”
. - iii. If your system supports both 2 backend options and is fully set up. When prompted, ensure the Use WSL 2 instead of Hyper-V option on the
Configuration page is selected or not depending on your choice of backend.
If your system only supports one of the two options, you will not be able to select which backend to use.
- iv. Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
- v. When the installation is successful, select Close to complete the installation process.
b. Install from the command line (winget)
- i. Windows Package Manager is integrated and available for use on Windows 10 from version 1809 and Windows 11.
- ii. Run
“winget --version”
to check if winget supported on system.
Administrator: C:\Windows\system32\cmd.exe
Microsoft Windows [Version 10.0.22631.3447]
(c) Microsoft Corporation. All rights reserved.
C:\Windows\System32>winget --version
v1.7.10861
C:\Windows\System32>
- iii. Search and install Docker Desktop with
winget
command. Enter “Y” if it asks to accept the license.
Administrator: Windows Powe X
PS C:\Users\admin> winget search Docker
Name Id Version Match Source
-----------------------------------------------------------------------------------------------------------
Dockerun 9NVBZPBTK78W Unknown msstore
Docker Desktop Docker.DockerDesktop 4.29.0 Moniker: docker winget
XPipe xpipe-io.xpipe 8.6 Tag: docker winget
dive wagoodman.dive 0.12.0 Tag: docker winget
Podman RedHat.Podman 5.0.1 Tag: docker winget
Kubernetes Without Kubelet Kubernetes.kwokctl 0.4.0 Tag: docker winget
kompose Kubernetes.kompose 1.31.2 Tag: docker winget
Outline Manager Jigsaw.OutlineManager 1.15.2 Tag: docker winget
Lazydocker JesseDuffield.Lazydocker 0.23.1 Tag: docker winget
Polar jamaljsr.Polar 2.2.0 Tag: docker winget
Haskell Dockerfile Linter hadolint.hadolint 2.12.0 Tag: docker winget
SimpleDockerUI felixgborrego.simple-docker-ui 0.5.5 Tag: docker winget
DockStation DockStation.DockStation 1.5.1 Tag: docker winget
Docker Compose Docker.DockerCompose 2.23.3 Tag: docker winget
Coder Coder.Coder 2.9.2 Tag: docker winget
Spice ChilliBits.Spice 0.19.5 Tag: docker winget
Compose Generator ChilliBits.ComposeGenerator 1.9.0 Tag: docker winget
Trivy AquaSecurity.Trivy 0.50.1 Tag: docker winget
Kubernetes Without Kubelet Kubernetes.kwok 0.5.1 Tag: docker winget
Docker Desktop Edge Docker.DockerDesktopEdge 2.5.4.50534 winget
Docker CLI Docker.DockerCLI 24.0.7 winget
lazydocker Bastian Pedersen.lazydocker 0.23.1 winget
PS C:\Users\admin> winget install Docker.DockerDesktop
Found Docker Desktop [Docker.DockerDesktop] Version 4.29.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://desktop.docker.com/win/main/amd64/145265/Docker%20Desktop%20Installer.exe
469 MB / 469 MB
Successfully verified installer hash
Starting package install...
Successfully installed
PS C:\Users\admin> |
Linux Installation
We can also install Docker Desktop for Linux or macOS. However, Linux are operating systems well-known for their command line interface and sometimes they do not have a graphical interface for us. Therefore, in this guide, we will focus on installing Docker Engine without using a GUI.
If you still want to install Docker Desktop with a graphical interface, here is the guide for you: [Docker Desktop for Linux](Docker Desktop for Linux) or [Docker Desktop for Mac](Docker Desktop for Mac).
1. Supported platform
Supported platforms
The platforms have been tested and verified installation by Docker
Check for the newest supported platforms at [Docker Supported Platforms](Docker Supported Platforms).
If you are using a Linux distribution/platform other than the ones above, follow these instructions to install Docker Engine: [Install Docker Engine on other Linux distros](Install Docker Engine on other Linux distros).
II. Install Docker Engine
Given the widespread popularity of Ubuntu Linux, let us start with it first.
Ubuntu
OS requirements: To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions: Ubuntu Mantic 23.10, Ubuntu Jammy 22.04 (LTS), Ubuntu Focal 20.04 (LTS)
nquangit@ubuntu-server:~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
nquangit@ubuntu-server:~$ |
Check version
Uninstall old versions: apt-get
might report that you have none of these packages installed.
nquangit@ubuntu-server:~$ for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker.io' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker-doc' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker-compose' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker-compose-v2' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'podman-docker' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'containerd' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'runc' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded.
nquangit@ubuntu-server:~$ |
Before you can install Docker Engine, you need to uninstall any conflicting packages
Installation methods:
As previously noted, Docker Engine can be installed with Docker Desktop. Additionally, there are alternative approaches available for installation.
- Docker’s apt repository.
- Install it manually and manage upgrades manually.
- Use a convenience script (Only recommended for testing and development environments).
- Install using the apt repository i. Set up Docker’s apt repository.
$ # Add Docker's official GPG key:
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl
$ sudo install -m 0755 -d /etc/apt/keyrings
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
$ sudo chmod a+r /etc/apt/keyrings/docker.asc
$ # Add the repository to Apt sources:
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
Install docker packages on Ubuntu.
- Install the Docker packages.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Install docker packages on Ubuntu.
ii. Verify that the Docker Engine installation is successful by running the hello-world image.
$ sudo docker run hello-world
If you see “Hello from Docker!” in your output, then the process was successful.
nquangit@ubuntu-server:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:03b30c6a3c320ff172b52bd68eddffde6ded08ce47e650fe52de861c5e9df46d
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
nquangit@ubuntu-server:~$ |
Check for Docker installation
- Install manually from a package i. Open your browser, and go to https://download.docker.com/linux/ubuntu/dists/ ii. Select your Ubuntu version from the list.
nquangit@ubuntu-server:~$ . /etc/os-release && echo "$VERSION_CODENAME"
jammy
nquangit@ubuntu-server:~$ source /etc/os-release && echo "$VERSION_CODENAME"
jammy
nquangit@ubuntu-server:~$ |
Check ubuntu version
iii. Go to pool/stable/
and select the applicable architecture (amd64, armhf, arm64, or s390x).
Index of linux/ubuntu/dists/
Index of linux/ubuntu/dists/jammy/pool/stable/
Find the appropriate packages for your operating system.
Check your architecture. x86_64 is equal to amd64.
iv. Download the following deb files for the Docker Engine, CLI, containerd, and Docker Compose packages:
* containerd.io_<version>_<arch>.deb
* docker-ce_<version>_<arch>.deb
* docker-ce-cli_<version>_<arch>.deb
* docker-buildx-plugin_<version>_<arch>.deb
* docker-compose-plugin_<version>_<arch>.deb
nquangit@ubuntu-server:~$ wget --quiet https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.31-1_amd64.deb
nquangit@ubuntu-server:~$ wget --quiet https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
nquangit@ubuntu-server:~$ wget --quiet https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
nquangit@ubuntu-server:~$ wget --quiet https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-buildx-plugin_0.13.1-1~ubuntu.22.04~jammy_amd64.deb
nquangit@ubuntu-server:~$ wget --quiet https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-compose-plugin_2.26.1-1~ubuntu.22.04~jammy_amd64.deb
nquangit@ubuntu-server:~$ ls
containerd.io_1.6.31-1_amd64.deb docker-ce_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
docker-buildx-plugin_0.13.1-1~ubuntu.22.04~jammy_amd64.deb docker-ce-cli_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
docker-compose-plugin_2.26.1-1~ubuntu.22.04~jammy_amd64.deb
nquangit@ubuntu-server:~$ |
v. Install the .deb
packages. Update the paths in the following example to where you downloaded the Docker packages.
$ sudo dpkg -i ./containerd.io_<version>_<arch>.deb \
./docker-ce_<version>_<arch>.deb \
./docker-ce-cli_<version>_<arch>.deb \
./docker-buildx-plugin_<version>_<arch>.deb \
./docker-compose-plugin_<version>_<arch>.deb
nquangit@ubuntu-server:~$ ls
containerd.io_1.6.31-1_amd64.deb docker-ce_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
docker-buildx-plugin_0.13.1-1~ubuntu.22.04~jammy_amd64.deb docker-ce-cli_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
docker-compose-plugin_2.26.1-1~ubuntu.22.04~jammy_amd64.deb
nquangit@ubuntu-server:~$ sudo dpkg -i containerd.io_1.6.31-1_amd64.deb docker-ce_26.0.1-1~ubuntu.22.04~jammy_amd64.deb docker-compose-plugin_2.26.1-1~ubuntu.22.04~jammy_amd64.deb docker-buildx-plugin_0.13.1-1
~ubuntu.22.04~jammy_amd64.deb docker-ce-cli_26.0.1-1~ubuntu.22.04~jammy_amd64.deb
Selecting previously unselected package containerd.io.
(Reading database ... 74446 files and directories currently installed.)
Preparing to unpack containerd.io_1.6.31-1_amd64.deb ...
Unpacking containerd.io (1.6.31-1) ...
Selecting previously unselected package docker-ce.
Preparing to unpack docker-ce_26.0.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce (5:26.0.1-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack docker-compose-plugin_2.26.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-compose-plugin (2.26.1-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack docker-buildx-plugin_0.13.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-buildx-plugin (0.13.1-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack docker-ce-cli_26.0.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-cli (5:26.0.1-1~ubuntu.22.04~jammy) ...
Setting up containerd.io (1.6.31-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.26.1-1~ubuntu.22.04~jammy) ...
Setting up docker-buildx-plugin (0.13.1-1~ubuntu.22.04~jammy) ...
Setting up docker-ce-cli (5:26.0.1-1~ubuntu.22.04~jammy) ...
Setting up docker-ce (5:26.0.1-1~ubuntu.22.04~jammy) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for man-db (2.10.2-1) ...
nquangit@ubuntu-server:~$ |
Install Docker Engine manually from package.
vi. Verify that the Docker Engine installation is successful by running the hello-world image.
$ sudo service docker start
$ service docker status # Check docker service status
$ sudo docker run hello-world
Check docker service status
Check for Docker installation
- Install using the convenience script
Note: Docker provides a convenient script to install Docker into development environments non-interactively isn’t recommended for production environments. Potential risks and limitations of the convenience 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. This may install a large number of packages, depending on the current configuration of your host machine.
- By default, the script installs the latest stable release of Docker, containerd, and runc. When using this script to provision a machine, this may result in unexpected major version upgrades of Docker. Always test upgrades in a test environment before deploying to your production systems.
- The script isn’t designed to upgrade an existing Docker installation. When using the script to update an existing installation, dependencies may not be updated to the expected version, resulting in outdated versions.
Command to install:
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh ./get-docker.sh --dry-run # Show what steps the script will run when invoked
$ sudo sh ./get-docker.sh
nquangit@ubuntu-server:~$ sudo sh ./get-docker.sh
#Executing docker install script, commit: e5543d473431b782227f8908005543bb4389b8de
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c install -m 0755 -d /etc/apt/keyrings
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor -yes -o /etc/apt/keyrings/docker.gpg
+ sh -c chmod a+r /etc/apt/keyrings/docker.gpg
+ sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
Version: 26.0.1
API version: 1.45
Go version: go1.21.9
Git commit: d260a54
Built: Thu Apr 11 10:53:21 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Version: 26.0.1
API version: 1.45 (minimum version 1.24)
Go version: go1.21.9
Git commit: 60b9add
Built: Thu Apr 11 10:53:21 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.31
GitCommit: e377cd56a71523140ca6ae87e30244719194a521
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-951d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
Install Docker Engine with convenience script
Check docker installation like Ubuntu Linux.
Debian/Kali
Ubuntu is derived from Debian, so the way to install Docker Engine is not too much different.
OS requirements: To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions: Debian Bookworm 12 (stable), Debian Bullseye 11 (oldstable).
Uninstall old versions:
$ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
✓ <kali@kali < 03:14:20]
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
[sudo] password for kali:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker.io' is not installed, so not removed
The following packages were automatically installed and are no longer required:
bluez-firmware certipy-ad firmware-ath9k-htc firmware-atheros firmware-brcm80211 firmware-intel-sound firmware-iwlwifi firmware-libertas firmware-realtek firmware-sof-signed firmware-ti-connectivity
firmware-zd1211 kali-linux-firmware libkf5config-bin linux-image-6.0.0-kali3-amd64 python3-cryptography37 python3-ntlm-auth python3-requests-ntlm
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2033 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker-doc' is not installed, so not removed
The following packages were automatically installed and are no longer required:
bluez-firmware certipy-ad firmware-ath9k-htc firmware-atheros firmware-brcm80211 firmware-intel-sound firmware-iwlwifi firmware-libertas firmware-realtek firmware-sof-signed firmware-ti-connectivity
firmware-zd1211 kali-linux-firmware libkf5config-bin linux-image-6.0.0-kali3-amd64 python3-cryptography37 python3-ntlm-auth python3-requests-ntlm
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2033 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
bluez-firmware certipy-ad firmware-ath9k-htc firmware-atheros firmware-brcm80211 firmware-intel-sound firmware-iwlwifi firmware-libertas firmware-realtek firmware-sof-signed firmware-ti-connectivity
firmware-zd1211 kali-linux-firmware libkf5config-bin linux-image-6.0.0-kali3-amd64 python3-cryptography37 python3-docker python3-dockerpty python3-ntlm-auth python3-requests-ntlm
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
docker-compose
0 upgraded, 0 newly installed, 1 to remove and 2032 not upgraded.
After this operation, 538 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 588134 files and directories currently installed.)
Uninstall conflict packages
Installation methods:
The process is similar to what you would do on Ubuntu.
- Install using the apt repository i. Set up Docker’s apt repository.
$ # Add Docker's official GPG key:
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl
$ sudo install -m 0755 -d /etc/apt/keyrings
$ sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
$ sudo chmod a+r /etc/apt/keyrings/docker.asc
$ # Add the repository to Apt sources:
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
Note: The script above only works with Debian, Kali Linux will get the following error: “E: The repository ‘https://download.docker.com/linux/debian kali-rolling Release’ does not have a Release file.”
$ # To fix that
$ # You can replace bookworm with bullseye, buster, stretch, wheezy or jessie.
$ sudo sed -i 's/kali-rolling/bookworm/g' /etc/apt/sources.list.d/docker.list
$ sudo apt-get update # Try to update again
✓ <kali@kali < 03:58:56]
sudo sed -i 's/kali-rolling/bookworm/g' /etc/apt/sources.list.d/docker.list
cat /etc/apt/sources.list.d/docker.list
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable
sudo apt-get update
Hit:1 https://download.docker.com/linux/debian bullseye InRelease
Get:2 https://download.docker.com/linux/debian bookworm InRelease [43.3 kB]
Get:3 https://download.docker.com/linux/debian bookworm/stable amd64 Packages [20.5 kB]
Hit:4 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:5 https://kali.download/kali kali-rolling InRelease
Hit:6 https://swupdate.openvpn.net/community/openvpn3/repos bullseye InRelease
Get:7 https://download.docker.com/linux/debian bookworm/stable amd64 Contents (deb) [1,340 B]
Fetched 65.2 kB in 5s (14.0 kB/s)
Reading package lists... Done
Add apt repository on Kali Linux
ii. Install the Docker packages.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
✓ <kali@kali < 03:58:56]
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
bluez-firmware certipy-ad firmware-ath9k-htc firmware-atheros firmware-brcm80211 firmware-intel-sound firmware-iwlwifi firmware-libertas firmware-realtek firmware-sof-signed firmware-ti-connectivity
firmware-zd1211 kali-linux-firmware libkf5config-bin linux-image-6.0.0-kali3-amd64 python3-cryptography37 python3-docker python3-dockerpty python3-ntlm-auth python3-requests-ntlm
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
docker-ce-rootless-extras
Suggested packages:
aufs-tools
The following packages will be upgraded:
containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin
6 upgraded, 0 newly installed, 0 to remove and 2042 not upgraded.
Need to get 120 MB of archives.
After this operation, 34.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://download.docker.com/linux/debian bullseye/stable amd64 containerd.io amd64 1.6.31-1 [29.8 MB]
Get:2 https://download.docker.com/linux/debian bookworm/stable amd64 docker-buildx-plugin amd64 0.13.1-1~debian.12~bookworm [29.5 MB]
Get:3 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce-cli amd64 5:26.0.1-1~debian.12~bookworm [13.8 MB]
Get:4 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce amd64 5:26.0.1-1~debian.12~bookworm [25.1 MB]
Get:5 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce-rootless-extras amd64 5:26.0.1-1~debian.12~bookworm [9,318 kB]
Get:6 https://download.docker.com/linux/debian bookworm/stable amd64 docker-compose-plugin amd64 2.26.1-1~debian.12~bookworm [12.4 MB]
Fetched 120 MB in 9s (13.1 MB/s)
(Reading database ... 588081 files and directories currently installed.)
Preparing to unpack .../0-containerd.io_1.6.31-1_amd64.deb ...
Unpacking containerd.io (1.6.31-1) over (1.6.22-1) ...
Preparing to unpack .../1-docker-buildx-plugin_0.13.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-buildx-plugin (0.13.1-1~debian.12~bookworm) over (0.10.4-1~ubuntu.20.04~focal) ...
Preparing to unpack .../2-docker-ce-cli_5%3a26.0.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce-cli (5:26.0.1-1~debian.12~bookworm) over (5:23.0.6-1~debian.11~bullseye) ...
Preparing to unpack .../3-docker-ce_5%3a26.0.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce (5:26.0.1-1~debian.12~bookworm) over (5:23.0.6-1~debian.11~bullseye) ...
dpkg: warning: unable to delete old directory '/etc/init': Directory not empty
Preparing to unpack .../4-docker-ce-rootless-extras_5%3a26.0.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:26.0.1-1~debian.12~bookworm) over (5:23.0.6-1~debian.11~bullseye) ...
Preparing to unpack .../5-docker-compose-plugin_2.26.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-compose-plugin (2.26.1-1~debian.12~bookworm) over (2.17.3-1~debian.11~bullseye) ...
Setting up docker-buildx-plugin (0.13.1-1~debian.12~bookworm) ...
Setting up containerd.io (1.6.31-1) ...
Setting up docker-compose-plugin (2.26.1-1~debian.12~bookworm) ...
Setting up docker-ce-cli (5:26.0.1-1~debian.12~bookworm) ...
Setting up docker-ce-rootless-extras (5:26.0.1-1~debian.12~bookworm) ...
Setting up docker-ce (5:26.0.1-1~debian.12~bookworm) ...
Installing new version of config file /etc/default/docker ...
Installing new version of config file /etc/init.d/docker ...
Removing obsolete conffile /etc/init/docker.conf ...
Processing triggers for man-db (2.11.2-3) ...
Processing triggers for kali-menu (2023.2.2) ...
Install Docker packages.
iii. Verify that the installation is successful by running the hello-world image:
$ sudo docker run hello-world
sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:03b30c6a3c320ff172b52bd68eddffde6ded08ce47e650fe52de861c5e9df46d
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
- Install manually from a package
This installation method is similar to Ubuntu Linux but there are some notes as follows:
- Resources: https://download.docker.com/linux/debian/dists/
- On Kali Linux, using
bookworm
orbullseye
are recommend for best compatibility.
- Install using the convenience script
Like Ubuntu Linux.
Uninstall Docker Engine
$ sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
Leave a comment