News & Updates

Ubuntu Install Docker CLI: Step-by-Step Guide

By Marcus Reyes 96 Views
ubuntu install docker cli
Ubuntu Install Docker CLI: Step-by-Step Guide

Getting started with Docker on Ubuntu is a straightforward process that unlocks a world of consistent and isolated application deployment. The combination of Ubuntu's robust Linux foundation and Docker's containerization technology provides developers and system administrators with a powerful toolkit for modern software engineering. This guide walks through the essential steps to install and configure the Docker CLI on your Ubuntu system, ensuring you are ready to build, ship, and run distributed applications.

Understanding Docker and Its Value on Ubuntu

Docker packages applications and their dependencies into lightweight, portable containers that run consistently across different environments. On Ubuntu, the Linux distribution's adherence to open standards and package management system makes it an ideal host for Docker. By leveraging namespaces and cgroups, Docker isolates processes and files, allowing multiple containers to share the same kernel without conflict. This efficiency eliminates the "it works on my machine" problem and streamlines the development lifecycle from testing to production.

Prerequisites and System Preparation

Before installing the Docker CLI, ensure your Ubuntu system is ready. It is recommended to use a 64-bit version of Ubuntu 20.04 or later. You should have a user account with sudo privileges to execute administrative commands. It is also good practice to update the local package index to guarantee you are installing the latest available version from the repository. Open a terminal and run the system update command to refresh your package lists.

Updating System Packages

Keeping the system current is a fundamental security and stability practice. Run the following command to install any available updates for existing packages. This ensures the installation process pulls the latest repository metadata and avoids potential conflicts with older versions.

sudo apt update && sudo apt upgrade -y

Installing Docker via the Official Repository

For the most stable and up-to-date experience, installing Docker from the official repository is the preferred method. This source is maintained by Docker Inc. and ensures you receive security patches and new features promptly. The process involves adding the GPG key for the official repository and setting up the repository itself on your Ubuntu machine.

Adding the Docker GPG Key and Repository

Secure package verification is handled by the GPG key. You will import the official Docker GPG key and add the stable repository to your apt sources list. This sequence of commands configures your system to trust packages downloaded from Docker's official channel.

sudo install -m 0755 -d /etc/apt/keyrings

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.gpg

sudo chmod a+r /etc/apt/keyrings/docker.gpg

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

Installing the Docker CLI and Engine

With the repository configured, you can now install the Docker packages. This will install the Docker CLI, the Docker daemon (engine), and other necessary dependencies. The package manager will handle downloading and configuring the software. After installation, the Docker daemon will start automatically, and the CLI will be ready to accept commands.

sudo apt update

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

Verifying the Installation

M

Written by Marcus Reyes

Marcus Reyes is a Senior Editor with 15 years of experience investigating complex global narratives. He brings razor-sharp analysis and unapologetic perspective to every story.