Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save radekkozak/b72e3cbde8501c58a0c065205eb31910 to your computer and use it in GitHub Desktop.
Save radekkozak/b72e3cbde8501c58a0c065205eb31910 to your computer and use it in GitHub Desktop.
Start up local Docker Machine on OSX automatically.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>{{user-path}}</string>
</dict>
<key>Label</key>
<string>com.docker.machine.default</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>/usr/local/bin/docker-machine start {{docker-machine-name}}</string>
<string>&&</string>
<string>eval</string>
<string>$(docker-machine env {{docker-machine-name}})</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Notice

This script is no longer required with Docker for Mac which includes an option to run Docker at startup and doesn't use docker-machine to administer the local Docker engine.

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine whose name is store in $DOCKER_MACHINE_NAME env var

Usage

The git.io URL (https://git.io/vHZiP) is a shortened form of the raw url of the plist.

$ curl -sL https://git.io/vHZiP | \
  sed -e "s?{{docker-machine}}?$(which docker-machine)?" \
      -e "s?{{docker-machine-name}}?$DOCKER_MACHINE_NAME?" \
      -e "s?{{user-path}}?$(echo $PATH)?" \
  >~/Library/LaunchAgents/com.docker.machine.default.plist && \
  launchctl load -w ~/Library/LaunchAgents/com.docker.machine.default.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment