You want to experiment with Docker but do not want to install it in your Windows host. I came across the same situation. Then I found a way to run and experiment with the Docker environment – trial and error – on a Virtual Box Ubuntu VM.
There you get the freedom to experiment with everything you can with a Docker installation, community version, and Ubuntu as the host machine.
For the simplicity of this guide, I assume that you have your VirtualBox Ubuntu VM up and running. If you need help with this, please refer to our quick guide on setting up Ubuntu 22.04 on VirtualBox. This guide will walk through the minimum required steps to make your local docker development setup ready in 10 minutes or less!
Step #1: Prepare your Ubuntu VM for Docker installation
Firstly, docker recommends cleaning up your existing docker references, if any. Just run the below commands.
sudo apt-get remove docker docker-engine docker.io containerd runc
Now, go with the very familiar ubuntu update commands, to make your Machine aware of the latest and greatest versions.
sudo apt-get update
Step #2: Run the prerequisites commands
Now, we will run recommended prerequisites commands
sudo apt-get install ca-certificates curl gnupg lsb-release
Prepare your environment further,
sudo mkdir -p /etc/apt/keyrings
Make sure to run the below command as one. (not in two lines)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Get the gpg, the GNU privacy guard (refer more here: gnupg.org )
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Run an update. I found this is required to avoid errors in upcoming commands.
sudo apt-get update
Step #3: Run the docker installer commands
Now, we are ready to fire the docker community edition installation command.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Step #4: Test your Docker environment installation
Your Ubuntu box is now ready to test your docker installation. Let us test it
sudo docker run hello-world
We have covered all steps required to install the Docker environment on Ubuntu 22.04 Operating system. We used a VirtualBox Virtual Machine for testing this configuration setup. Note that the scope of this guide is a complete guide to setting up the basic docker host on Linux. You will have to secure your environment with advanced steps if you prepare the docker host for production environments.