HomeTech TutorInstalling Docker on Ubuntu: A Step-by-Step Guide

Installing Docker on Ubuntu: A Step-by-Step Guide

Ubuntu is a popular Linux distribution for developers to streamline code and deployment activities. Here's how to install Docker on Ubuntu.

- Advertisement -

Ubuntu is a popular Linux distribution for developers to streamline code and deployment activities. In this post, we shall be looking at how to install Docker on Ubuntu and leverage the capabilities of Docker as a containerization platform. Docker is a popular application to build and deploy containers, in contrast to virtual machines which are bulkier and less manageable. Docker has thus revolutionized the DevOps process.

Before You Begin

This post assumes you are working on Ubuntu and have it installed.  It does not matter which Ubuntu distribution you are using but having any LTS version or latest version is preferred. Also, it is necessary to have sudo privileges on Ubuntu users.

It is also required that you have a basic understanding of Docker and how it works. You will need to understand Docker images and containers. Docker supports registries such as the JFrog registry, from where you can download and utilize the images. Docker Hub is also another registry where you can download the images. Make sure you have an account on any registry.

Installing Docker on Ubuntu

To install Docker on Ubuntu, you must follow the below steps:

  1. Update your packages in the repository
  2. Enable fetch packages over HTTPS
  3. Adding Docker repository to the APT sources
  4. Installing docker
  5. Verifying Installation

1. Update your packages in the repository

It is always recommended to update the packages in the repository so that you are using stable code and have updated security packages.

Also Read:  5 Features You Should Seek In An Ideal Linux Device Management Tool

Ubuntu uses APT to store and install the software.

- Advertisement -
sudo apt update

2. Enable fetch packages over HTTPS

HTTPS is a preferred protocol for only transfers. This ensures that your connection is secured and encrypted. To install Docker, you need to have packages installed on HTTPS. Run the below command to enable HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

3. Adding Docker Repository to APT sources

You need to add the Docker repository to the APT sources. This will enable APT to access the Docker repository and download sources. To add Docker repository to APT sources run the below command:

- Advertisement -
sudo add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/ubuntu bionic stable"

4. Installing Docker

To install the Docker, first update the Docker packages:

sudo apt update

Install Docker from the Docker repo instead of the default Ubuntu repo:

- Advertisement -
apt-cache policy docker-ce

Finally, install Docker using the below command:

sudo apt install docker-ce

5. Verifying Docker Installation

We have completed all the steps needed to install the Docker. Docker must be installed, daemon service started, and the Docker process starts on boot. Check this by running the command below:

sudo systemctl status docker

Hello World using Docker

There is another interesting way to make sure that the Docker is up and running. This is by running the Hello World image in Docker. Docker image is a blueprint that is used to build Docker containers of the application. Docker containers are built from Docker images. By default, Docker pulls these images from Docker Hub, a Docker registry managed by Docker. Docker Hub is open to everyone to upload their images. Most applications and Linux Distributions are hosted there, ready to be used. To check whether you can access and download images from Docker Hub, run the below command:

Also Read:  How to Link NIN to Airtel Line (Airtel NIN Code) in 2022

In your terminal, run the below command:

docker run hello-world

Now, the Docker will first try to find the image locally. If it cannot find the image locally, it will proceed to download the image from the remote repository. Now since this image is lightweight, it will not take much time to download, however, for heaver images, download can be time-consuming.

Once the download has been done, and the container has been made, you will see the below output:

Hello from Docker!
This message shows that your installation appears to be working correctly.

You can also create your images and publish them on Docker Hub. You can even set up a Docker repository. Publishing the images online helps in sharing your work with others and also makes the images manageable. Docker also supports tagging the images. This means that in the remote repository, you can have different versions and when downloading the image, you can specify the version you want to use. This is very similar to Git versioning if you have experience with version control using Git.

Conclusion

This was a bit lengthy post, but we learned how to install Docker on Ubuntu. Both Ubuntu and Docker are popular with the developers and their combined stack can simplify your development cycle and cut infrastructure costs, as in the case of Virtual Machines.

- Advertisement -
Naijaknowhow Team
Naijaknowhow Teamhttps://naijaknowhow.net
This is the profile of our team of prolific writers who create amazing tech-related content. The information contained on this website is for general information purposes only and does not represent the opinion of Naijaknowhow Media.

2 COMMENTS

Hey fam, don't go without a reply!

ADVERTISE NAIJAKNOWHOW
- Advertisment -

Latest Posts

- Advertisment -
- Advertisment -