Join our Discord Server
Adesoji Alu Adesoji brings a proven ability to apply machine learning(ML) and data science techniques to solve real-world problems. He has experience working with a variety of cloud platforms, including AWS, Azure, and Google Cloud Platform. He has a strong skills in software engineering, data science, and machine learning. He is passionate about using technology to make a positive impact on the world.

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

3 min read

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

Docker Engine is a powerful tool for managing containers and is widely used in software development. In this guide, we will walk you through the process of installing Docker Engine on Ubuntu. Before we begin, make sure your system meets the necessary prerequisites.

Prerequisites

Firewall Limitations

Warning: Before installing Docker, it is crucial to consider the following security implications and firewall incompatibilities:

  • If you use ufw or firewalld to manage firewall settings, be aware that when you expose container ports using Docker, these ports bypass your firewall rules.
  • Docker is only compatible with iptables-nft and iptables-legacy. Ensure that any firewall rules you create are done with iptables or ip6tables.

OS Requirements

To install Docker Engine, you need the 64-bit version of one of the following Ubuntu releases:

  • Ubuntu Noble 24.04 (LTS)
  • Ubuntu Jammy 22.04 (LTS)
  • Ubuntu Focal 20.04 (LTS)

Docker Engine for Ubuntu is compatible with the following architectures: x86_64 (or amd64), armhf, arm64, s390x, and ppc64le.

Uninstall Old Versions

Before you can install Docker Engine, you need to uninstall any conflicting packages. Run the following command:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

This command will remove any conflicting packages. Note that images, containers, volumes, and networks stored in /var/lib/docker/ won’t be removed automatically.

Installation Methods

You can install Docker Engine in various ways, depending on your needs:

  • Bundled with Docker Desktop for Linux (easiest and quickest).
  • Set up and install Docker Engine from Docker’s APT repository.
  • Install it manually and manage upgrades manually.
  • Use a convenience script (recommended only for testing environments).

Install Using the APT Repository

To install Docker Engine via the APT repository, follow these steps:

Set Up Docker’s APT Repository

Add Docker’s official GPG key:

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add the repository to Apt sources:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install the Docker Packages

To install the latest version of Docker Engine, run:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

To verify the installation, run:


sudo docker run hello-world

This command downloads a test image and runs it in a container, confirming that the installation was successful.

Upgrade Docker Engine

To upgrade Docker Engine, follow the installation instructions again, choosing the new version you wish to install.

Install from a Package

If you can’t use Docker’s APT repository, download the .deb files for the Docker Engine, CLI, containerd, and Docker Compose packages from the following site: Docker Repository.

Install the .deb Packages

Update the paths accordingly:


   sudo dpkg -i ./containerd.io__.deb \
  ./docker-ce__.deb \
  ./docker-ce-cli__.deb \
  ./docker-buildx-plugin__.deb \
  ./docker-compose-plugin__.deb

Start the Docker service:


sudo service docker start

Then verify the installation again:


sudo docker run hello-world

Convenience Script Installation

For a non-interactive installation, you can use the convenience script provided by Docker:


curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

However, this method is not recommended for production environments.

Uninstall Docker Engine

To uninstall Docker Engine, run:

sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

To remove all images, containers, and volumes, execute:


sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

Remember to delete any edited configuration files manually.

Conclusion

Following these steps, you can successfully install and configure Docker Engine on your Ubuntu system. Whether you are using it for development or production, Docker provides a robust environment for container management.

Have Queries? Join https://launchpass.com/collabnix

Adesoji Alu Adesoji brings a proven ability to apply machine learning(ML) and data science techniques to solve real-world problems. He has experience working with a variety of cloud platforms, including AWS, Azure, and Google Cloud Platform. He has a strong skills in software engineering, data science, and machine learning. He is passionate about using technology to make a positive impact on the world.

Install Docker Desktop on Windows

Install Docker Desktop on Windows This blog contains the download URL, information about system requirements, and instructions on how to install Docker Desktop for...
Adesoji Alu
1 min read

Leave a Reply

Join our Discord Server
Index