To install Docker on Ubuntu, follow these steps:
Update your existing list of packages:
sudo apt update
Install packages to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker APT repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the package database with the Docker packages from the newly added repo:
sudo apt update
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
apt-cache policy docker-ce
Install Docker:
sudo apt install docker-ce
Check that Docker is running:
sudo systemctl status docker
(Optional) Manage Docker as a non-root user:
sudo usermod -aG docker ${USER}
To install Docker Desktop on Windows, follow these steps:
Download Docker Desktop for Windows from the official Docker website.
Run the Docker Desktop Installer, which you just downloaded, and follow the installation instructions.
Open PowerShell as Administrator and run:
wsl --install
Start Docker Desktop from the Start menu.
Follow the guided onboarding to build your first container.
Open PowerShell and run:
docker --version
To install Docker Desktop on MacOS, follow these steps:
Download Docker Desktop for Mac from the official Docker website.
Open the downloaded Docker.dmg file and drag Docker to Applications.
Run Docker Desktop from the Applications folder.
Follow the installation process and authorize the installer with your system password.
Open Terminal and run:
docker --version
This will set up Docker Desktop on all three platforms: Ubuntu, Windows, and MacOS.
You can check that Docker is working by running:
$ docker run -it hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:0b6a027b5cf322f09f6706c754e086a232ec1ddba835c8a15c6cb74ef0d43c29
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/