Skip to main content
Welcome to this comprehensive guide on installing Docker on an Ubuntu virtual machine. In this lesson, we will cover the process of setting up an Ubuntu VM, installing Docker, and running Docker containers.
Ensure that you are connected to your Ubuntu VM via SSH from your laptop before proceeding.

Step 1: Becoming the Root User

To start, switch to the root user by running the following command:

Step 2: Installing Docker on Ubuntu

Install Docker by using the apt-get package manager to install the Docker package (docker.io). This command will install Docker along with all the necessary dependencies.
After confirming the installation, Docker will be installed on your system. To verify the installation, display Docker’s help page by running:

Step 3: Checking the Docker Version

To confirm the installed version of Docker on your Ubuntu VM, execute the following command:
Verifying the Docker version ensures that your installation was successful and provides details about both the Client and Server components.

Step 4: Running the “hello-world” Docker Container

Now that Docker is installed, let’s run a simple container to confirm that Docker is functioning correctly. Use the following command to run the “hello-world” container. This command will automatically pull the image from Docker Hub if it is not already available locally, and then display a confirmation message.

Step 5: Running the “whalesay” Docker Container

For a bit of fun, let’s run another Docker image called “whalesay.” This container uses the “cowsay” program to display a message along with an ASCII art whale. Execute the command below:
Once the image is pulled, the container runs and produces the following output:

Conclusion

In this lesson, we demonstrated how to install Docker on an Ubuntu virtual machine and run Docker containers. You’ve learned to:
  • Become the root user.
  • Install Docker and its dependencies.
  • Confirm the installation by checking the Docker version.
  • Run the “hello-world” and “whalesay” containers to verify that Docker is working correctly.
Enjoy exploring Docker further and discovering more about containerization!

Additional Resources

Happy Dockering!

Watch Video