Docker install, docker command and Issues
Complete guide to start Linux OS and install essential applications in Linux
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.
Step 1: Uninstall old versions and Update OS
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
Step 2: Install Docker
Now, Install docker by the following command-
sudo apt install docker.io
Step 3: Install all the dependency packages
sudo snap install docker
Step 4: Check the version
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
Step 5: hello-world Image:
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.
Docker Commands:
There is some command regarding Docker:
- Check Docker pulled images
By following command, you can check the docker image has been pulled and is present in your system -
sudo docker images
- Display all the containers pulled
To display all the containers pulled, use the following command:
sudo docker ps -a
- Check for containers
To check for containers in a running state, use the following command:
sudo docker ps
Issues:
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
docker image ls
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