• Articles

How to Install Docker on Ubuntu?

How to Install Docker on Ubuntu?

Docker has revolutionized the world of software development by introducing a lightweight and efficient containerization platform. By encapsulating applications and their dependencies into isolated containers, Docker simplifies deployment and eliminates compatibility issues. 

Understanding how to utilize Docker in Ubuntu will enhance productivity and enable seamless application deployment. Let’s dive in and discover how to set up Docker on Ubuntu.

Watch this video on DevOps Tutorial for 2023:

Video Thumbnail

What is Docker?

What is Docker

Docker is an open-source platform that enables programmers to use containerization to simplify the deployment and maintenance of programs. Containers are lightweight, portable, and isolated environments that encapsulate an application and its dependencies. 

By utilizing Docker, developers can build, package, and distribute applications with their configurations, libraries, and dependencies consistently. It provides a standardized workflow for building, shipping, and running applications in different environments. 

Docker simplifies the process of software development, encourages collaboration, and improves scalability. Moreover, it enables you to create a container once and run it on any Linux-based system, known as Ubuntu.

Become a DevOps Expert through Intellipaat’s DevOps Certification Course.

System Requirements for Installing Docker on Ubuntu

Before installing Docker in Ubuntu, let’s verify that your system meets the important requirements. Docker is compatible with different versions of Ubuntu, such as Ubuntu 16.04, 18.04, 20.04, and their corresponding derivatives. To aim for optimal performance, use 64-bit Ubuntu. Here are a few requirements listed below:

  • System Compatibility: To run Docker, you need a system with a compatible Linux kernel. Ubuntu 64-bit systems running kernel version 3.10 or above are generally consistent. It’s essential to have a supported version of Docker that matches your Ubuntu release. Docker provides official repositories for Ubuntu, ensuring easy installation and updates.
  • Sufficient Resources: Ensure your system has sufficient resources to run Docker smoothly. A minimum of 2 GB of RAM is recommended, although more is beneficial for running multiple containers simultaneously. Docker relies on the Linux kernel’s features, so it’s crucial to have a modern and stable version of the kernel.
  • Enabled Hardware Virtualization: Additionally, Docker requires a 64-bit processor with hardware virtualization support. Most modern CPUs, such as those from Intel or AMD, meet this requirement.

By ensuring your system meets these requirements, you’ll be ready to proceed with the installation process and unlock the power of Docker on Ubuntu.

Want to learn more? Check out our DevOps tutorial.

Cloud Computing EPGC IITR iHUB

Installing Docker on Ubuntu

Docker Installation process on Ubuntu

Installing Docker on Ubuntu is a straightforward process. Follow the steps below to get Docker up and running on your Ubuntu system:

  1. Update Package Lists: Begin by updating the package lists on your system. Open a terminal and run the following command:
SQL:
sudo apt update
  1. Install Necessary Packages: Docker requires a few additional packages to work correctly. Install them by running the following command:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
  1. Add Docker’s GPG Key: Download and add Docker’s official GPG key to ensure package integrity. Use the following command to import the key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg - dearmor -o/usr/share/keyrings/docker-archive-keyring.gpg
  1. Add Docker Repository: Add the Docker repository to your system’s software sources by running the Docker command that matches your Ubuntu version:
  • For Ubuntu 20.04
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | sudo tee/etc/apt/sources.list.d/docker.list > /dev/null
  • For Ubuntu 18.04
echo "deb [arch=amd64 keyring.gpg] signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]https://download.docker.com/linux/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  • For Ubuntu 16.04
echo "deb [arch=amd64signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu xenial stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Install Docker Engine: Update the package lists once more and proceed to install Docker by running the following command:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
  1. Verify Docker Installation: After the installation completes, verify that Docker is installed correctly by running the following command:
sudo docker run hello-world
  • If Docker is installed correctly, you’ll see a “Hello from Docker!” message, indicating a successful installation.

Congratulations! You have successfully installed Docker on your Ubuntu system. Now you’re ready to start utilizing the power of Docker containers for your development and deployment workflows.

Preparing for an Interview? Go through these DevOps Interview Questions.

Bootcamp in Cloud Computing and DevOps

Uninstall Docker in Ubuntu

If you no longer require Docker on your Ubuntu system or need to perform a clean reinstallation, it’s essential to uninstall Docker properly. 

To uninstall Docker on Ubuntu, you can follow these steps:

  • Stop Docker Services: Before removing Docker, stop any running Docker services by executing the following command:
sudo systemctl stop docker
  • Uninstall Docker Packages: To remove Docker packages from your system, run the following command:
sudo apt purge docker-ce docker-ce-cli containerd.io
  • Delete Docker Configuration Files: Remove any remaining Docker configuration files and directories using the command below:
sudo rm -rf /etc/docker /var/lib/docker
  • Delete Docker User: If you no longer need the Docker user, you can delete it by running the following command:
sudo userdel -r docker
  • Delete Docker Images, Containers, and Volumes (Optional): If you wish to remove all Docker images, containers, and volumes, use the following command:
sudo rm -rf /var/lib/docker
  • Verify Uninstallation: Run the command below to confirm that Docker has been uninstalled successfully. Docker has been completely removed from your Ubuntu system if no output is displayed.
docker --version

By following these steps, you can ensure a clean and complete uninstallation of Docker from your Ubuntu system.

Difference between Podman vs Docker, the two popular containerization tools, to help users make an informed choice.

Get 100% Hike!

Master Most in Demand Skills Now!

Conclusion

This comprehensive guide covers the essential aspects of installing Docker on Ubuntu. Docker is a powerful containerization platform that offers numerous benefits for developers and system administrators, including improved security, portability, resource efficiency, and reproducibility. Understanding the concept of Docker and verifying system requirements is crucial before starting the installation process. Following the step-by-step instructions in this guide, you can successfully install Docker on your Ubuntu system and leverage its capabilities.

Crack your next job interview with ease. Find the most commonly asked Docker Interview Questions for 2024 here!

Course Schedule

Name Date Details
AWS Certification 16 Nov 2024(Sat-Sun) Weekend Batch View Details
23 Nov 2024(Sat-Sun) Weekend Batch
30 Nov 2024(Sat-Sun) Weekend Batch

EPGC-Cloud.jpg