It is a very easy and straightforward process to install Docker on Ubuntu. With just a few simple steps, you can quickly get Docker up and running on your Ubuntu system.
Install Docker on Ubuntu
Before you can use Docker Engine on your system, you must first set up the Docker repository. Once this is done, you can install and update Docker from the repository.
Add the Official Docker GPG Key for Ubuntu
Run the following commands to add the Official Docker GPG Key to your Ubuntu system.
sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
Add the repository to Apt sources:
You can now run the following command
echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] 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 the Docker Packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify the install
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
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/
You have now successfully installed Docker on your Ubuntu system!
You can stay up to date with the Docker releases by running the following commands:
sudo apt update sudo apt upgrade
This will update your docker install along with any other outdated packages you may have. It’s that easy!
Once installed, you can then start using Docker for whatever tasks you need it for. Additionally, you can use the command line interface to control Docker, or you can use one of the many GUI applications available for Docker. If you like this content, please check out our other Homelab Guides