I have some makefiles where most of the stuff should run without configuration. These makefiles have used docker-machine
in the past.
Is there a way to detect in Bash if the user is using Docker Desktop for Mac instead of docker-machine
?
The best way is to check for the existence of the DOCKER environment variables:
All four of these are set when eval $(docker-machine env)
is run and are required for use with docker-machine.
The beta does not require any of them being set and in fact requires you to unset them in order to function properly.
You can also do a check in the docker info
command looking for "moby" (the name of the docker for mac VM):
docker info | grep -q moby && echo "Docker for mac beta" || echo "Not docker for mac beta"
This is going to be dependent on consistency in the docker info
results, however.