how to install docker on ubuntu?

 

Docker is an open-source platform that allows you to run applications in containers. These containers are lightweight and portable, which makes it easier to manage and deploy applications. 

Below are the steps to be followed to install Docker on Ubuntu:

Step 1: Update the package list Before installing Docker, it is recommended to update the package list of your Ubuntu system. You can do this by running the following command:

Step 2: Install Docker: To install Docker on Ubuntu, you can use the official Docker repository. Follow the steps below:

  1. Add the Docker GPG key to your system:

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


  1. Add the Docker repository to APT sources:

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

 

  1. Update the package list again:

sudo apt-get update

 

  1. Finally, install Docker:

sudo apt-get install docker-ce

 

Step 3: Verify the installation After installing Docker, you can verify that it is working correctly by running the following command:

sudo docker run hello-world

 

This command will download a small Docker image and run it in a container. If everything is working correctly, you should see the following output:

Hello from Docker!

 

This message shows that your installation appears to be working correctly.

Step 4: Manage Docker as a non-root user By default, Docker requires root privileges to run. However, you can configure Docker to be managed by a non-root user. Follow the steps below:

  1. Create a new group called docker:

sudo groupadd docker

  1. Add your user to the docker group:

sudo usermod -aG docker $USER

 

  1. Log out and log back in to apply the group membership changes.
  2. Verify that you can run Docker commands without sudo:

docker run hello-world

 

Step 5: Use Docker Compose (optional) Docker Compose is a tool that allows you to define and run multi-container Docker applications. To install Docker Compose, follow these steps:

  1. Download the latest version of Docker Compose:

sudo curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

 

  1. Apply executable permissions to the binary:

sudo chmod +x /usr/local/bin/docker-compose

 

  1. Verify that the installation was successful:

docker-compose –version

 

Conclusion In this guide, we have the process on how to install Docker on Ubuntu. We also covered how to manage Docker as a non-root user and how to install Docker Compose. 

 

Comments