Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

How to install Docker on Ubuntu

This is a step by step docker installation guide on ubuntu. Before proceeding docker installation, I am uninstalling all the docker related packages so I can start it from fresh. Below command is used to uninstall docker packages.

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Docker package removal log showing unsuccessful attempts to remove non-installed packages before install on ubuntu.

First step is configure docker repository using below commands and update the apt-get system on ubuntu.

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

A screenshot of a terminal window showing the installation of Docker on an Ubuntu system, including commands and output

Using below commands install docker packages and its components.

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

 Terminal log showing the successful installation of Docker CE, Docker CE CLI, containerd.io, Docker Buildx plugin, and Docker Compose plugin on an Ubuntu system.

Once packages are installed successfully. Verify docker version and install test container on docker to check everything is working fine. For more and in dept installation and configuration information check official documentation:- https://docs.docker.com/engine/install/ubuntu/

docker version
sudo docker run hello-world

Terminal screenshot showing the Docker version details and a successful test run of the hello-world image, confirming Docker installation is working correctly.

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.51/containers/json": dial unix /var/run/docker.sock: connect: permission denied

If you don't have sudo access and you are receiving above error. You will need to provide one time access to docker group to current user using following command.

 

#sudo groupadd docker #optional
sudo usermod -aG docker $USER 
# sudo usermod -aG docker ${$USER}
reboot -f

ansible awx docker sudo groupadd docker sudo usermod -aG docker $USER reboot docker.sock permission denied container ansible tower.png

Useful Articles
How to install Docker on Linux
Cannot connect to the Docker daemon at unix:var run docker.sock. Is the docker daemon running
Docker Error response from daemon i\o timeout internet proxy
How to install Ansible on Linux for vSphere configuration
How to Setup Passwordless SSH Login on Windows
configure remote ssh extension on visual studio code
VS code remote ssh could not establish to host, connecting was canceled

Go Back

Comment

Blog Search

Page Views

13060090

Follow me on Blogarama