docker on mac without docker-desktop

I just had a discussion where I was told that docker-desktop isn’t usable anymore because of their new licensing. So I had a look if docker-desktop is really required. In the end it is just a nicer integration with some desktop app to manage the background vm.

I installed virtualbox and set up a vm with shared host adapter for being able to easily access it via ip. On that ubuntu vm which I access from outside via SSH I installed docker as documented on the official docker documentation and gave my user proper rights to use docker. The vm has proper internet access and can run docker containers with ports mapped to the shared host adapter.

From my mac I installed docker via brew (not desktop) and added a context for the vm:

docker context create vm --description "local ubuntu vm" --docker "host=ssh://manuel@ubuntu"

The “ubuntu” hostname was added to my /etc/hosts with the configured ip of the vm and manuel is my ssh user on the vm.

With the new context created the context list looks like this:

➜  ~ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                KUBERNETES ENDPOINT   ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                          swarm
desktop-linux       moby                                                          unix:///Users/manuel/.docker/run/docker.sock                         
vm                  moby                local ubuntu vm                           ssh://manuel@ubuntu

After switching the context to `vm` I can easily work with docker running on the vm.

docker context use vm

With the use of context I was able to come around docker-desktop completely. So the argument that docker isn’t usable anymore on a non linux machine is busted.