How can I detect if docker for mac is installed?

The cleanest way I found so far is:

[[ $(docker version --format "{{.Server.KernelVersion}}") == *-moby ]]

The best way is to check for the existence of the DOCKER environment variables:

  • DOCKER_HOST
  • DOCKER_MACHINE_NAME
  • DOCKER_TLS_VERIFY
  • DOCKER_CERT_PATH

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.