DEV Community

Cover image for Docker Installation
Kannan
Kannan

Posted on

Docker Installation

What is Docker?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.

What is Docker Container

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application.
Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space.

Lets start the Docker Installation on Ubuntu
Step 1:Update and install the system dependencies before install docker

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
sudo apt-get install ca-certificates curl gnupg -y
Enter fullscreen mode Exit fullscreen mode

Step 2: Add GPG (GNU Privacy Guard) key is used to ensure the authenticity of the packages that are being downloaded from Docker

sudo install -m 0755 -d /etc/apt/keyrings
Enter fullscreen mode Exit fullscreen mode
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Enter fullscreen mode Exit fullscreen mode
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
Enter fullscreen mode Exit fullscreen mode

Step 3: Now we start install Docker & Docker plugins

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Enter fullscreen mode Exit fullscreen mode
  • InstallDocker-Compose Plugins
curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode
ls -lsh /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode
chmod +x /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode
  • Verify the Docker & Docker compose version
 docker version && docker-compose version
Enter fullscreen mode Exit fullscreen mode
  • Restart,enable the Docker service
sudo systemctl restart docker 
sudo systemctl enable docker 
Enter fullscreen mode Exit fullscreen mode
  • Check the status of Docker service
sudo systemctl status docker
Enter fullscreen mode Exit fullscreen mode

Step 4: Create a Docker Group and add user to the group

sudo groupadd docker
Enter fullscreen mode Exit fullscreen mode
sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode
newgrp docker
Enter fullscreen mode Exit fullscreen mode

Finally Docker Engine Installation was successfully completed

Top comments (0)