How to Install Docker on Ubuntu

Docker is a platform that packages the application and all its dependencies in the container so that the application works seamlessly. The Container makes the application run its resource in an isolated process similar to the virtual machines, but it is more portable. 

For a detailed introduction to the different components of a Docker container, you can check out Introduction to Docker, Docker Containers & Docker Hub 

This tutorial covers the installation and use of Docker Community Edition (CE) on an Ubuntu 20.04 machine. 

This tutorial is meant for those who are interested in learning Docker as a container service 

If you want to use Ubuntu 20.04 without making any change to the Windows Operating system, you can proceed with the Oracle Virtual box.  

Virtual Box is free and open-source virtualization software from Oracle. It enables you to install other operating systems in virtual machines. It is recommended that the system should have at least 4GB of RAM to get decent performances from the virtual operating system. 

Navigate to the website of Oracle Virtual Box, download the .exe file and get the latest stable version. 

How to Install Docker on Ubuntu

1. Once done with downloading the virtual box, we can navigate toand download the  Ubuntu disk image (.iso file) by clicking on the download option How to Install Docker on Ubuntu

2. Once the download has been completed for Ubuntu .iso file, open the virtual box and click on “New” present on top.  How to Install Docker on Ubuntu3. Enter the details of your virtual machine by giving any name, type as “Linux ” and Version as Ubuntu (64 bit)  How to Install Docker on Ubuntu

4. Choose the memory (RAM ) that needs to be allocated to the Virtual machine  and click on Next. (I have chosen 3000 MB ) How to Install Docker on Ubuntu

5. After the RAM allocation ,Click on  Create a virtual disk now. This serves as the hard disk of the virtual Linux system. It is where the virtual system will store its files How to Install Docker on Ubuntu

6. Now, we want to select the Virtual Hard Disk.  

How to Install Docker on Ubuntu

7. We can choose either the “Dynamically allocated” or the “Fixed size” option for creating the virtual hard disk. 

How to Install Docker on Ubuntu

8. Finallywe have  to specify our Ubuntu OS’s size. The recommended size is 10 GB, but it  can be increased if required.How to Install Docker on Ubuntu

8. Finallywe have  to specify our Ubuntu OS’s size. The recommended size is 10 GB, but it  can be increased if required.
How to Install Docker on Ubuntu
9. Ubuntu OS is ready to install in Virtual Box, but before starting the Virtual system, we need to make few changes in settings. Click on storage under the setting.  

How to Install Docker on Ubuntu

10. Click on Empty under Controller IDE. Navigate to Attributes and browse the Optical Drive option. 

11. Choose the .iso file from the location where it is downloaded. Once selected, click on OK and start the Virtual box by clicking on start present on the Top menu.How to Install Docker on Ubuntu

12. Click ok and start the machine. 

13. Proceed with Install Ubuntu How to Install Docker on Ubuntu

How to Install Docker on Ubuntu

14. Under “Updates and other software” section, check “Normal installation”, and the two options under “Other options” and continue.How to Install Docker on Ubuntu

15. In Installation type, check Erase disk and install Ubuntu.How to Install Docker on Ubuntu

16. Choose your current location and set up your profile. Click Continue.  How to Install Docker on Ubuntu

17. It may take 10-15 minutes to complete the installation 

18. Once the installation finishes, restart the virtual systemHow to Install Docker on Ubuntu

We are done with pre-requestand can now proceed with using this Ubuntu. 

One of the easiest ways is the installation of Docker from the standard Ubuntu 20.04 repositories, but It’s possible that the Ubuntu default repositories have not updated to the latest revision of Docker. It happens because in some cases Docker is not supporting that particular Ubuntu version. Therefore, there can be scenario where  Ubuntu default repositories have not updated to the latest version. 

How to Install Docker on Ubuntu

How to Install Docker on Ubuntu

How to Install Docker on Ubuntu

To install Docker from Ubuntu default repositories, use the below command: 

How to Install Docker on Ubuntu

To check the installed version, use the below: 

How to Install Docker on UbuntuSince discussed above, it has installed the 19.03.8 version of docker whereas the latest version is 20.04  

For installing docker on ubuntu 20.04 with the latest version, we’ll proceed with enabling the Docker repository, importing the repository GPG key, and finally installing the package. 

To install the docker on Ubuntu box, update your existing list of packages. It will ask for a password. Enter it and allow the system to complete the updates. 

How to Install Docker on Ubuntu

We need to install a few prerequisite packages to add HTTPS repository : 

sudo apt install apt-transport-https ca-certificates curl software-properties-common How to Install Docker on Ubuntu

Import the repository’s GPG key using the followingcurl command: 

curl –fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add – How to Install Docker on Ubuntu

Add the Docker APT repository to the system 

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

How to Install Docker on Ubuntu

Again, update the package database with the Docker packages 

Finally, install Docker using below command: 

How to Install Docker on Ubuntu

To check the installed version use below: 

How to Install Docker on Ubuntu

To start, enable and check the status of docker, use below command: 

How to Install Docker on Ubuntu

To check system wide information regarding docker installation, we use the command “docker info”. Information that is shown includes the kernel version, number of containers and unique images. 

The output will contain details as given below, depending upon the daemon running: 

Source:

Note: In case you get below error after running “docker info” commandone way is to add sudo in front and run the command, OR you can refer to the same error-resolving steps mentioned under Running Docker Images section. How to Install Docker on Ubuntu

To check whether you can access and download the images from Docker Hub, run the following command: 

How to Install Docker on UbuntuIn case of errors received after running the docker run command, you can correct it using the following steps, otherwise proceed with the next step of checking the image. 

ERROR: docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sockconnect: permission denied. See ‘docker run –help’.   

Create the docker group if it does not exist 

Add your user to the docker group. 

Eg:- sudo usermod –aG docker kanav 

Run the following command or Logout and login again and run ( if that doesn’t work you may need to reboot your machine first) 

Check if docker can be run without root 

If the problem still continues, try to reboot it and run the command. 

To check the image, use this command: 

How to Install Docker on Ubuntu

Below are the common commands used to remove images and containers: 

To completely uninstall Docker, use below: 

To identify what are the installed packagesthis is the command: 

How to Install Docker on Ubuntu

Conclusion: 

If you found this Install Docker on Ubuntu blog relevant and useful, do check out the Docker-Training workshop from KnowledgeHut, where you can get equipped with all the basic and advanced concepts of Docker! 

  • Ubuntu 20.04 64-bit operating system. (If Linux OS is not in system, we can run docker using Virtual Box, PFB the steps) 
  • A user account with sudoprivileges 
  • An account on Docker Hub to pull or push an image from Hub. 
  • Log in to Virtual BoxRun “docker” as command to check if it is previously installed.
  • To install Docker on Ubuntu box, first update the packages. It will ask for a password. Enter it and allow the system to complete the updates.
  • To install Docker from Ubuntu default repositories, use the below command: 

  • To check the installed version, use the below: 

  • To install the docker on Ubuntu box, update your existing list of packages. It will ask for a password. Enter it and allow the system to complete the updates. 

  • We need to install a few prerequisite packages to add HTTPS repository : 

  • Import the repository’s GPG key using the followingcurl command: 

  • Add the Docker APT repository to the system 

  • Again, update the package database with the Docker packages 

  • Finally, install Docker using below command: 

  • To check the installed version use below: 

  • To start, enable and check the status of docker, use below command: 

  • Create the docker group if it does not exist 

  • Add your user to the docker group. 

  • Run the following command or Logout and login again and run ( if that doesn’t work you may need to reboot your machine first) 

  • Check if docker can be run without root 

  • To check the image, use this command: 

  • To identify what are the installed packagesthis is the command: 

  • To remove images, containers, volumes, or user created configuration files, these commands can be used: 
  • sudo rm -rf /var/lib/docker /etc/docker 
  • sudo rm /etc/apparmor.d/docker 
  • sudo groupdel docker 
  • sudo rm -rf /var/run/docker.sock  
  • Research & References of How to Install Docker on Ubuntu|A&C Accounting And Tax Services
    Source

    error: Content is protected !!