How to install docker on Ubuntu

Introduction

Docker is a powerful platform that allows you to develop, ship, and run applications inside containers. Installing Docker on Ubuntu is a straightforward process. This guide will walk you through the steps to install Docker on Ubuntu, ensuring you have a smooth and efficient experience.

Prerequisites

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

1. Update Your System

Before installing any new software, it’s always a good practice to update your system’s package index. Open a terminal and run the following command:

sudo apt update

2. Install Required Packages

To ensure that your system can use the HTTPS protocol to fetch packages, install these prerequisite packages:

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

3. Add Docker’s Official GPG Key

This step ensures the authenticity of the software packages by adding Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4. Add Docker Repository to Ubuntu

Add the Docker repository to APT sources:

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

This command adds the stable repository which is recommended for production environments.

5. Install Docker Engine

First, update the package database with the Docker packages from the newly added repo:

sudo apt update

Now, install Docker:

sudo apt install docker-ce

6. Verify Docker Installation

To ensure Docker was installed correctly, you can run the Hello World container:

sudo docker run hello-world

If Docker is correctly installed, you will see a message indicating that your Docker installation is working correctly.

7. Manage Docker as a Non-Root User

By default, Docker requires administrator privileges. To run Docker commands without sudo, add your user to the docker group:

sudo usermod -aG docker ${USER}

Log out and log back in so that your group membership is re-evaluated.

8. Enable and Start Docker Service

To have Docker start at boot, enable the service:

sudo systemctl enable docker

To start the Docker service, use:

sudo systemctl start docker

9. Update Docker (Optional)

Docker is updated regularly. To update it, simply use the standard system update process:

sudo apt update
sudo apt upgrade

Conclusion

Docker is now installed and ready to use on your Ubuntu system. You can begin containerizing your applications and taking advantage of Docker’s powerful features for development and deployment. Remember to check Docker’s official documentation for more advanced features and best practices.

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock