Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gilgamez/485f7c45082ab098822f to your computer and use it in GitHub Desktop.
Save gilgamez/485f7c45082ab098822f 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.{{machine-name}}</string>
<key>ProgramArguments</key>
<array>
<string>{{docker-machine}}</string>
<string>start</string>
<string>{{machine-name}}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).

Usage

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

$ curl -sL https://git.io/v2tb5 | \
    sed -e "s?{{docker-machine}}?$(which docker-machine)?" \
        -e "s?{{machine-name}}?$(echo $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