Rabikant

Posted on November 15th

How to install Docker On Ubuntu

"In this blog we learn how to setup and install Docker on ubuntu"

What is Docker?

### Introduction to Docker

Docker was launched in 2013 by Docker, Inc. as an open source project with the utilization of the concept of the container. It gives developers the ability to automate the application deployment within ‘light-weight’ containers. But, Docker makes containerization easy and puts the capability within the reach of all users.

How Docker Works

At its core, Docker uses the following components to manage and run containers:At its core, Docker uses the following components to manage and run containers:

  1. Docker Engine: This is the runtime that is responsible for the creation of containers along with their administration. This entails a server which is a long-lived daemon process called ‘dockerd’ and an HTTP based REST API through which programs may send instructions to the daemon process.
  2. Docker Images: An image is a snapshot of how that a Docker container is structured and how it is to be built. Some of the components consist of the application code, runtime environment such as Python or Java, application libraries, environment variables, and configuration files. Docker images are constructed from text file known as Dockerfile which is the script used to construct an image.
  3. Docker Containers: A container is a process of a running image of Docker. When a container is started it acts as a minute isolated space in which an application is executed. By their design, containers are automatically transient; that is, they can be shutdown and restarted with no influence to the outer environment.
  4. Docker Hub: Docker Hub is a cloud service that provides registry of the containers. It has a large collection of official and ordinary users photo albums. While containerizing the application, a developer can either use his own custom images or can use the images which are already available in the Docker Hub.
  5. Docker Compose: This is a tool that is used in defining and also for the launching of multi-container Docker applications. If you’ve chosen using Docker Compose, you can describe services, networks, volumes in YAML, and then create/start all the related services by this configuration with a single call.
  6. Docker Swarm: Docker Swarm can be described as the clustering and orchestration tool provided by Docker. It makes it possible to have varying instances of Docker engines whereby, services can be spread across a number of machines thus enhancing availability and scalability factors.

Use Cases

Docker is used in a wide range of scenarios, including:

  • Development and Testing: Developers use Docker in order to build reliable environments that resembled production. This makes it possible for code written locally be able to work as expected once it is deployed.
  • Continuous Integration and Continuous Deployment (CI/CD): Docker plays a central role in today’s CI/CD pipeline where it facilitates testing and deployment of applications.
  • Microservices: Docker can be particularly effective in microservices architecture since applications are divided into several, smaller and more independent services.
  • Legacy Application Modernization: Legacy applications can easily be containerized by docker and can easily run them on the modern infrastructure with minimal changes in the code.

What is Ubuntu?

Ubuntu is one of the most well known implementation of GNU/Linux based on the Debian distribution, created with the idea of reaching as many users as possible. This is among the most popular and common used Linux distributions which gains popularity among both, newcomers and experienced Linux specialists due to its convenient interface, numerous users’ contributions and high level of security.

Overview

  • Ubuntu Operating system was published in October, 2004 by Canonical Ltd., a company established by an South Africa’s entrepreneur Mark Shuttleworth. The name Ubuntu itself has origins in African languages and has connotations of ‘humanity towards others and was due to the project’s emphasis on the community as well as the affordability of cars.

Ubuntu is free to download, use, and share, and it comes in several flavors, each tailored to different use cases:Ubuntu is free to download, use, and share, and it comes in several flavors, each tailored to different use cases:

  • Ubuntu Desktop: The standard version as for personal computers and laptops. It also has a graphical user interface and comes with a preloaded software, for example, Firefox internet browser, Libre Office suite and several multimedia applications.
  • Ubuntu Server: A Web server version to meet the needs of developers and provide a fast, robust and secure environment for web hosting and cloud computing or data centers. That is it has no graphical user interface as default because it is intended for server tasks and optimized for performance.
  • Ubuntu Core: IoT and embedded systems lightweight, lock-down version which utilizes snaps (self-contained application packages for security and to avoid hiccups).
  • Ubuntu Studio: A creative edition targeted towards artists and designers who will get to edit audio, video, stencils, and graphics in a single application.
  • Ubuntu Kylin: A version that were designed with the Chinese government’s endorsement, and adjusted to Chinese conditions and preferences.

Features of Ubuntu

  1. User-Friendly Interface: The underlying GUI environment of Ubuntu has always been based on GNOME, although, Ubuntu switched from its in-house developed Unity in 2017. One of the best things about Lubuntu is that it provides a bright and clear interface which provides an opportunity to work for an average user who doesn’t want to deal with Linux deeply.
  2. Software and Package Management* It utilizes the APT (Advanced Package Tool) as the package manager which makes it very convenient in the installation, updating and removal of this software. It also supports a special kind of package called “snap” packages; which are applications that contain all necessary dependencies.
  3. Security: One of Ubuntu’s strengths is the security of this operating system. Hence, it emphasizes security with features such as update, LTS versions, and security features such as firewalls and encryptors.
  4. Community and Support: Ubuntu has a powerful and dynamic community base that participates in the development of its new versions and also help in case of problems that a user may face. It has professional support services, thus making it suitable for businesses and enterprises to obtain their products from Canonical.
  5. Customization: Ubuntu is Extremely configurable When implemented it provides an exceptionally high degree of customization. Some of the things that users can do include, selecting various graphical interfaces, adjusting the configuration and changing the looks of the operating system.
  6. Performance: The Ubuntu is very friendly to all types of systems ranging from the older generation and the current systems. This is especially infamous for its stability and more importantly operational performance, which qualifies for both the desktop and server uses.

Install Docker

Step 1: Update Your System

First, it's important to update your system's package index to ensure that all packages and repositories are up-to-date. Open your terminal and run the following command:

sudo apt-get update

This command updates the list of available packages and their versions but does not install or upgrade any packages.

Step 2: Install Docker.io

Now, you can install Docker using the following command:

sudo apt install docker.io

Step 3: Install Docker dependency

Install the docker dependency package by using the given command:

$ sudo snap install docker

Step 4: Verify Docker Installation

After the installation, verify that Docker is installed correctly by checking the version:

sudo docker --version

You should see output similar to Docker version 20.10.12, build e91ed57 indicating that Docker is installed and ready to use.

Step 5: (Optional) Manage Docker as a Non-Root User

By default, Docker requires root privileges. To avoid using sudo every time you run a Docker command, add your user to the docker group:

sudo usermod -aG docker $USER

After running this command, log out and log back in for the group membership to take effect.

Step 6: Start and Enable Docker

Ensure Docker is running and set it to start automatically on boot:

sudo systemctl start docker
sudo systemctl enable docker
  • systemctl start docker: Starts the Docker service immediately.
  • systemctl enable docker: Configures Docker to start at boot.

Test Docker Installation

Finally, test Docker by running a simple container:

sudo docker run hello-world

This command downloads and runs a sample Docker image, which prints a confirmation message to the terminal.

Comments

Leave a comment.

Share your thoughts or ask a question to be added in the loop.