I think the point of using docker is not having to use virtual machines
That is the point if you are on Linux. But Docker containers share the Linux kernel so they don’t run natively on Windows or macOS. Docker Desktop secretly runs a Linux VM under the covers and makes it look like its running natively on Windows but it is not. There is actually a VM that gets started when you start Docker.
I ended up installing Ubuntu in a VM on VirtualBox to try docker
If you want tp make your VirtualBox experience even better, try adding Vagrant. Vagrant will orchestrate the provisioning of the VM for you. It does this with a file called Vagrantfile
. Here is a simple Vagrantfile
that will provision and Ubuntu 20.04 VM and install docker
and docker-compose
automatically.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-20.04"
config.vm.network :private_network, ip: "192.168.33.10"
# Provision memory and cpus
config.vm.provider :virtualbox do |vb|
vb.memory = "2048"
vb.cpus = 2
end
# Provision Docker and Docker-Compose
config.vm.provision :docker
config.vm.provision :docker_compose
end
Once you install Vagrant and create this file, you can start the VM and enter it with:
vagrant up --provider virtualbox
vagrant ssh
You can then use docker from within this VM. The cool part is that it maps a folder called /vagrant
to the current folder on your computer. So all of your files from your PC are available inside the virtual machine under /vagrant
.
You can end your session with:
exit
vagrant halt
You can delete the VM with:
vagrant destroy
This is a great way for all developers on a team to have a consistent environment with docker regardless if they use macOS, Windows, or Linux.