0

Is it possible to distinguish whether a user is using Docker Toolbox or Docker for Mac/Windows?

I've already seen this.

In order to do some tests, now I have both Docker for Mac and Docker Toolbox installed and running. I can run Docker for Mac simply by running:

docker

and Docker Toolbox by running:

DOCKER_MACHINE_NAME=default DOCKER_CERT_PATH=$HOME/.docker/machine/machines/default DOCKER_TLS_VERIFY=1 DOCKER_HOST=tcp://192.168.99.100:2376 docker.

As answered here. I tried checking DOCKER_TOOLBOX_INSTALL_PATH env var, but in my case is empty. Then I thought that I could check whether the scheme of DOCKER_HOST is tcp and consider it to be Docker Toolbox, but then I realized that even with Docker for Mac is possible to have tcp scheme for DOCKER_HOST.

I then ran docker system info for both Docker for Mac and Docker Toolbox. I noticed that in the first case there's:

Operating System: Docker for Mac

while in the second case:

Operating System: Boot2Docker 18.09.4 (TCL 8.2.1)

Is it safe then to check whether OperatingSystem contains case-insensitive the string boot2docker for both Mac and Windows?

se7entyse7en
  • 4,310
  • 7
  • 33
  • 50
  • Why does it matter? Also consider the (ill-advised) possibility of a remote `$DOCKER_HOST` and more complex setups like a Docker container using the host's Docker socket, and environments like Kubernetes where interacting directly with Docker is generally discouraged. – David Maze Apr 10 '19 at 16:52
  • Because I'm working on an application that currently doesn't support Docker Toolbox, so I want to perform a check upfront instead of raising some unexpected errors that give no clue about the incompatibility with Docker Toolbox. – se7entyse7en Apr 10 '19 at 17:41

0 Answers0