Today we will learn How to install Docker on Ubuntu. To start with Docker on Ubuntu by following our easy-to-follow installation guide. Learn how to install and configure Docker on your Ubuntu system and leverage the power of containerization to streamline your development process. A technology called Docker allows users to run applications in packages and containers. Like virtual machines in that they are isolated, containers are more portable and resource-friendly.
Enables you to build and run apps on any Docker host, helping to make Docker applications portable. From your laptop to the cloud, Docker is available where a container image can be used without modification.
This eliminates the distinction between runtime contexts, simplifying the developer experience. Furthermore, the container architecture makes it easy to spread programs across different physical servers in response to changing demands.
In this context, we’ll show you how to install and use Docker in Ubuntu.
Using the official repositories to install Docker
To ensure that you have the latest stable application version, install Docker from the official Docker repository. Install Docker after adding new package sources to Ubuntu to access the official Docker repository. The steps are as follows:
Step 1: Updating the package repository
The system package repository can be updated, and the most recent required packages installed, by running the following command:
sudo apt update
To continue the upgrade, enter your root password when prompted and press Enter.
Step 2: Install the prerequisite packages
To use packages over HTTPS, apt package manager requires some prerequisite packages to be installed on the system. To enable Ubuntu to access the Docker repositories via HTTPS, enter the following command:
sudo apt install apt-transport-https ca-certificates curl software-properties-common –y
Above command:
- Enables file and data transfer over HTTPS for the app.
- Enables the system to verify security credentials.
- Installs the data-transfer program curl.
- Adds scripts for managing software.
Step 3: Add the GPG key
A GPG key verifies the validity of a software package. Run the following code to add the GPG key for the docker repository on your machine:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
Ensure correctness and display the results correctly.
Step 4: Add the Docker repository
To add the Docker repository to the appropriate sources, use the following command:
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable”
This command updates the package database with the latest Docker packages and adds the official Docker repository.
Step 5: Determine the installation source
To confirm that the Docker installation source is the Docker repository and not the Ubuntu repository, run the apt-cache command.
The apt-cache tool looks for previously added Docker packages in the cache of the apt package manager.
Execute the command line:
apt-cache policy docker-ce
The output identifies the most recent version of the newly inserted source repository.
Step 6: Install Docker on Ubuntu
To install Docker on Ubuntu, use the below command:
sudo apt install docker-ce –y
Keep it closed until the installation completes.
Step 7: Check Docker Status
Verify that Docker is set up, the daemon is running, and the process is set to boot. Run the command line:
sudo systemctl status docker
Install Docker on Ubuntu from the default repository
Another way to install Docker on Ubuntu is to use the default Ubuntu repositories. Although installation is easy, the Docker package may not be the latest version. If you don’t care about the latest version, the instructions below will help you install Docker using the default repository.
Step 1: Updating the Repository
Run this code to ensure that the local system package repository is updated:
sudo apt update
When prompted, enter the root password and wait for the process to complete.
Step 2: Install Docker
To install Docker, use this command:
sudo apt install docker.io –y
Any prompts during installation are automatically answered with yes if the -y parameter is specified.
Step 3: Install Dependencies
Use the following command to install all the Docker dependency packages:
sudo snap install docker
This command uses the Snap Package Manager to install all dependencies.
Step 4: Verify the installation
Use the status command or check the program version to see if Docker is installed correctly. Run this command to see the docker daemon status:
sudo systemctl status docker
You can run the following command to determine the software version:
docker –version
Installing Docker on Ubuntu using the installation script
The docker convenience script automates the installation of all docker components. Since it’s not interactive, you can relax while your system prepares for you.
Download the script first:
curl -fsSL https://get.docker.com -o get-docker.sh
Now run the script with root permissions:
sudo sh get-docker.sh
Running the docker install script
Wait until the writing is finished. A confirmation message should appear indicating Docker installation.
The script is intended to be a universal remedy. Its actions cannot be changed without explicitly changing the script’s source code.
Also, since it won’t update dependencies to recent versions, it’s not intended to do Docker updates.
Conclusion
A well-liked tool for building and distributing software in packages called containers is called Docker. One of the most popular Linux distributions is Ubuntu, and Docker provides strong support for this operating system. By setting up Docker on Ubuntu, you can create a perfect platform for your development projects using small virtual machines that share the Ubuntu kernel.



