You are currently viewing Installing and Configuring Docker on Ubuntu

Installing and Configuring Docker on Ubuntu

Let’s start with Docker on Ubuntu

Docker is a popular platform for developing, shipping, and running applications inside containers. This allows for consistent environments for applications and simplifies deployment. Below is a step-by-step guide to install and configure Docker on an Ubuntu Linux system.

Prerequisites

  • An Ubuntu system (version 18.04, 20.04, or later is recommended).
  • A user account with sudo privileges.
  • An active internet connection.

Step 1: Update Your Package Repository and install required packkages

Before installing Docker, updating the package repository ensures you get the latest version of Docker. Open a terminal and run:

sudo apt update
sudo apt upgrade -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

Step 2: Add Docker’s Official GPG Key and Docker APT Repository

To verify the packages you download, add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update

Step 3: Install Docker, Enable Docker and verify the installation

You can now install Docker by running:

sudo apt install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER
sudo systemctl start docker
sudo systemctl enable docker
sudo docker --version

Full script to install Docker on Ubuntu

#!/bin/bash

# Update packages and install required dependencies
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Add Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io

# Add the current user to the 'docker' group 
sudo usermod -aG docker $USER

# Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker

# Verify Docker version and installation
docker --version

Conclusion

You have successfully installed and configured Docker on your Ubuntu Linux system! Docker streamlines the process of application development and deployment through containerization, allowing you to easily manage your applications.

Feel free to explore Docker’s extensive documentation to learn more about its features and best practices for container management. Happy Dockerizing!

Leave a Reply