Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine.
Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall using following command:
sudo apt-get remove docker docker-engine docker.io containerd runc
It’s OK if apt-get reports that none of these packages are installed.
Check if the system is up-to-date using the following command:
sudo apt-get update
Now, Install docker by the following command-
sudo apt install docker.io
sudo snap install docker
Before going to work with Docker, check the version installed using the following command:
docker --version
This will shows as like if Docker is installed successfully
Docker version 20.10.12, build e91ed57
Pull hello-world image from the Docker hub using the following command:
sudo docker run hello-world
Here, hello-world is the docker image present on the Docker hub.
This is all about installing docker on Ubuntu.
There is some command regarding Docker:
By following command, you can check the docker image has been pulled and is present in your system -
sudo docker images
To display all the containers pulled, use the following command:
sudo docker ps -a
To check for containers in a running state, use the following command:
sudo docker ps
Issue 1:
If following comment executing, shows message: permission denied,
docker image ls
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json": dial unix /var/run/docker.sock: connect: permission denied
For remedy this, you have add group:
sudo groupadd docker
groupadd: group 'docker' already exists
sudo usermod -aG docker $USER newgrp docker
after that, run command again
Output:
REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 3 months ago 13.3kB php 5.6-fpm 3458979c7744 2 years ago 344MB
...............
Thanks