Docker is an open-source platform that allows developers to build, ship, and run applications in containers.
Docker containers are portable, meaning they can run consistently across different operating systems and environments (development, testing, production). This eliminates the "works on my machine" issue, ensuring applications behave predictably regardless of the underlying infrastructure.
In this post we will discuss how to install docker on ubuntu operating systems or on ubuntu virtual machines.
so without further delay, let's start.
The first method is :-

  1. power on your ubuntu system or launch ubuntu virtual machine on
    Azure or AWS or GCP .

  2. Open terminal if you are in GUI mode or for virtual machines "ssh" into the virtual machines.

  3. Take the root user privilege with the help of following command
    root access

  4. Update the local packages

    update

  5. Run the following command
    getscript
    Above command downloads the script get-docker.sh to your local system/virtual machine from https://get.docker.com/

  6. To install the above script (get-docker.sh) run the following command
    runscript
    The get-docker.sh installs the latest stable release of Docker on Linux

  7. Enable docker services

    enable

  8. Check the status of docker service if it is running or not
    status
    The above command shows the following output of docker is running
    service-ok
    and it is showing in green that docker service is active and running.

  9. Start the docker daemon
    daemon

To check docker service run the following command
hello
The above command pulls the image "hello-world" from docker hub to your local system/virtual machine executes it and throws a hello message.
The out put is as follows.
hlo-wrld

The second method is :-

  1. power on your ubuntu system or launch ubuntu virtual machine on
    Azure or AWS or GCP .

  2. Open terminal if you are in GUI mode or for virtual machines "ssh" into the virtual machines.

  3. Take the root user privilege with the help of following command
    root access

  4. Update the local packages

    update

  5. Install docker
    install

  6. Enable docker services

    enable

  7. Check the status of docker service if it is running or not
    status
    The above command shows the following output of docker is running
    service-ok
    and it is showing in green that docker service is active and running.

  8. Start the docker daemon
    daemon

To check docker service run the following command
hello
The above command pulls the image "hello-world" from docker hub to your local system/virtual machine executes it and throws a hello message.
The out put is as follows.
hlo-wrld
Finally you are ready to work with docker.

Note:- although The docker service starts automatically on Debian based distributions but it is advisable the check the services by using systemctl command as shown in this article.