On my current team, we're still transitioning from Docker Toolbox to Docker Desktop for Windows. A lot of our scripts still assume that you're running Docker Toolbox on VirtualBox (like how to mount drives, how slashes or drive names work for those mounts).
Is there a reliable way to tell, from inside a script, whether docker
is coming from Docker Toolbox or Docker Desktop for Windows?
Toolbox works via
docker-machine
. The way thedocker
client is directed to the virtual machine is via a number of environment variables which you can see by runningdocker-machine env default
Docker for Mac connects directly to the
/var/run/docker.sock
socket which is mapped into the Docker VM so this is easy to detect by the lack of environment variables.I believe Docker for Windows uses a named pipe in the same way (
//./pipe/docker_engine
) so you should also be able to tell by the lack ofDOCKER_HOST
in the environment.If Docker for Windows does still use the environment, there will be differences between the Toolbox and Docker for Windows variables.
DOCKER_HOST
would be on a different range.DOCKER_CERT_PATH
won't includemachine
etc.