Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stevenmaguire/3290f93a616560e624dd to your computer and use it in GitHub Desktop.
Save stevenmaguire/3290f93a616560e624dd 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>{{docker-machine}}</string>
<string>start</string>
<string>{{docker-machine-name}}</string>
<string>&&</string>
<string>eval</string>
<string>"$(docker-machine env {{docker-machine-name}})"</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Requirements

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

Usage

http://git.io/vcj2P is a shortened url for the raw plist file.

$ curl -sL http://git.io/vcj2P | \
    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 ~/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