Today we will see how we can install docker in our ubuntu 20.04 and on our windows 10 computer. This installation process will be very easy and anyone can follow it to install docker easily. So let’s now see how we can install docker.
First of all i will show you how to install docker in ubuntu 20.04 after that we will see how to install it in windows 10 if you want to install in windows then scroll down or select windows from the table of contents.
Install docker on ubuntu 20.04 –
Before installing Docker in our Ubuntu system, we have to setup a docker repository after which we will install docker in it.
Setup Docker Repository –
Update System –
To install Docker in ubuntu, first we will update our Ubuntu packages i.e. update its apt packages, for which we will use the command given below –
sudo apt-get update
Install important packages –
Now we will install some such packages in our ubuntu system which will allow apt to use a repository with https. Packages that we are going to install is – apt-transport-https which will allow us to access repository via https, ca-certificate, curl which we need for data transfer from any server, gnupg-agent , software-properties-common. To install all these packages, we will use the commands given below.
sudo apt-get install apt-transport-https -y
sudo apt-get install ca-certificates -y
sudo apt-get install curl -y
sudo apt-get install gnupg-agent -y
sudo apt-get install software-properties-common -y
Add gpg key –
Now we will add the gpg key to it, which we use to sign files and check their signature.
To install the GPG key, we will type the following command in our terminal which is –
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
After typing the above command, GPG key will be installed in your ubuntu and it will show OK in your terminal, if OK does not show then check your command whether it is correct or not. you might have pasted the command wrong.
To check whether our GPG key is installed or not, we can use the command given below to verify it.
sudo apt-key fingerprint 0EBFCD88
When we type this command in terminal, the terminal will show us the fingerprint of our GPG key which means that GPG key is now installed in our ubuntu system.
Add Repo to Apt –
Now we will add our repository to apt for which we will use the command given below.
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”
In this command we have written stable because we want to install only the stable version of docker for which we have added the stable repository. You can also install different versions of docker, but I recommend the stable version only.
In place of [arch=amd64] you will need to write the architecture of your system, which can be different in everyone’s system, remove amd64 and give the architecture of your system. To know the architecture of your system, you have to go to System monitor where you can see your architecture in the system option, this will show you what architecture your device is made up of.
Install Docker –
Now we will see the process of installing Docker-engine, for which we will first update the apt packages of our system again.
sudo apt-get update
After this we will install docker and also along with docker we will also install its cli and containerd.io.
sudo apt-get install docker-ce -y
sudo apt-get install docker-ce-cli -y
sudo apt-get install containerd.io -y
Docker is now successfully installed in our system, to check that you can type some of the commands given below.
Which are used to check the version of docker and to check if docker can run a container or not.
” docker –version ” This command will show you the version of docker which version of docker is installed in your system. If it says ” command not found ” then it means that docker is not installed in your system.
By typing this command “sudo docker run hello-world” if you see “Hello from docker” in terminal then it means that docker is working properly and can run a container.
[lyte id=’cm6m5ZkiWRI’ /]
Install Docker on Windows 10 –
Now let us see how to install docker in windows 10 which is very easy. So let us now see the process of installing docker in windows.
To install docker, first we have to download docker exe file which we will find in docker official website – “https://www.docker.com/products/docker-desktop” go to this link and then Click on Download for windows, after which the exe file of docker will be downloaded in your computer.
Enable Hyper-V Feature –
Before installing Docker in windows, we have to enable Hyper-V feature of windows which we need to run and install docker.
Enable Virtualization –
Before enabling Hyper-V, we have to see whether Virtualization is enabled in our windows computer or not, for which we will open our task manager and there we will go to performance where we will see Virtualization at the bottom of the right side. If it is disabled then you have to enable it now, for which you follow the steps given below.
To enable virtualization, you have to first click on the windows logo and then click on settings. By going to the settings, we will get updates and security.
Here we will go to the recovery option, here we will click on the option of restart which is under the advanced startup, after you click that, the computer will restart.
Now we will get some options on our screen in which we have to select troubleshoot option and then we have to select advanced options. Now we will get many options here out of which we have to click on “UEFI Firmware settings” and then we have to click on restart button.
Here now we have to select the bios setup for which we will use our function keys because here you cannot use the mouse. After selecting it with the help of function keys, press enter.
Now we will click on system configuration here after which we will go to Virtualization technology and press enter. Now we will go down with the help of our arrow keys and select Enabled instead of Disabled. After this we will select save and exit with the help of our function keys and after that our system will automatically restart normally.
After restarting we will have to check whether virtualization is now enabled or not, you can open your task manager where you will have to go to performance where you will get the option of virtualization and there you will need to see whether it is enabled or disabled.
After virtualization is enabled, to enable Hyper-V, we will first have to search Hyper-V in the search bar of windows and then open the windows features. Now here we have to select Hyper-V and then click on OK, after that Hyper-V will be installed in it, after which we will have to restart our computer again.
Hyper-V is not available in all windows computers only in professional, education and pro versions.
After restarting, we will have to go to the search bar again and search for Hyper-V there. Now we will open it, after opening we have to click on the virtual switch manager in the right side and then there we will have to select the new virtual network.
Here we will choose the external option and then click on create virtual switch and then we will click on OK after which Hyper-V is now enabled completely.
If you are facing any problem in enabling Hyper-V then you can search on YouTube how we can install Hyper-V in windows 10 and you will get many videos with the help of which you can easily install it on your windows 10 and can enable Hyper-V in the computer.
Install Docker on windows –
Now that we have enabled Hyper-V, now we can install our docker, we will run the exe file we downloaded to install it and then we will come to the setup wizard of docker. Where we have to click on OK, after which our docker installation will start.
It will take some time to install, after which docker will be installed in your Windows 10.
Once installed, you will have to restart your windows computer once. After restarting, you can now search docker in your search bar.
To know whether docker is installed or not, you have to open your command prompt where you have to type “docker –version” which will show you the version of docker which means that docker has been installed.
And just like in ubuntu, to see if its container is working properly or not you have to type hello world command “docker run hello-world” which will pull hello world image from docker library which means your container is working fine. This means that docker is now installed in your Windows 10 and is working properly.
Frequently asked questions –
Could not get lock /var/lib/dpkg/lock error while installing docker in ubuntu.
If you are also getting this error while installing docker, then it means that some process is running in your system which you have to stop first so that you can proceed.
It is very easy to fix this error. When your terminal shows you this error, along with it it also shows an ID which you need to fix this problem.
You get an ID which is something like “It is held by process 0000” Here our ID is 0000 which is different for everyone.
To fix this error, we will use the command given below, where at the end we will enter our ID which we want to stop.
sudo kill 0000
After typing this command that process will stop and then you can proceed with your docker installation process.
Where is Docker easier to install? Ubuntu or Windows –
It is easier to install Docker in ubuntu as compared to windows because in windows you have to enable many such settings which are not easy for non-technical person. Due to which many people do not prefer to install docker in windows.
If you talk about ubuntu, it is very easy to install docker in it, you just have to type some commands in terminal which will install docker in your ubuntu 20.04.
Can we install docker on different versions of ubuntu using this tutorial?
Yes, you can install docker in different versions of ubuntu also with the help of this tutorial because if you are using different version of ubuntu then the steps are same and you will not have any problem in installing it.
If you liked this tutorial, then definitely share it with your friends who want to install docker on their ubuntu linux and windows 10. And if you have any question, then you can comment it in the comment section below, which I will definitely solve it for you. Thank you.