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

It is always recommended to update the packages in the repository so that you are using stable code and have updated security packages. Ubuntu uses APT to store and install the software.

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:

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:

4. Installing Docker

To install the Docker, first update the Docker packages: Install Docker from the Docker repo instead of the default Ubuntu repo: Finally, install Docker using the below command:

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:

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: In your terminal, run the below command: 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: 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.

Installing Docker on Ubuntu  A Step by Step Guide   - 54Installing Docker on Ubuntu  A Step by Step Guide   - 84Installing Docker on Ubuntu  A Step by Step Guide   - 59Installing Docker on Ubuntu  A Step by Step Guide   - 40Installing Docker on Ubuntu  A Step by Step Guide   - 68