Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 89 You must be signed in to star a gist
  • Fork 21 You must be signed in to fork a gist
  • Save andystanton/257fab335b242bc2658b to your computer and use it in GitHub Desktop.
Save andystanton/257fab335b242bc2658b 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>default</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 called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).

Usage

$ curl -sL https://gist.githubusercontent.com/andystanton/257fab335b242bc2658b/raw/c62ae413a0a45ec5d832fb04065a085a8fb477da/com.docker.machine.default.plist | \
    sed -e "s?{{docker-machine}}?$(which docker-machine)?" \
        -e "s?{{user-path}}?$PATH?" \
    >~/Library/LaunchAgents/com.docker.machine.default.plist && \
    launchctl load ~/Library/LaunchAgents/com.docker.machine.default.plist
@msabramo
Copy link

This worked great for me. Thanks, @andystanton!

@rantoniuk
Copy link

Good job, thanks @andystanton!

@jbarlow83
Copy link

For homebrew users:
brew services start docker-machine

@andysign
Copy link

In my case the entire process of starting up the docker-machine was slow... because of that I was forced to add the following:
while [ "$(docker-machine ls --filter name=default -f '{{.Error}}')" != "" ] && [ "$(docker-machine ls --filter name=default -f '{{.URL}}')" == "" ]; do sleep 1; done; eval $(docker-machine env default);
in
.bash_profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment