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.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: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.