Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chusiang/1f3da70b832abff4af3b to your computer and use it in GitHub Desktop.
Save chusiang/1f3da70b832abff4af3b to your computer and use it in GitHub Desktop.
run docker-machine on system startup - Mac OSX - El Capitan
<?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>Label</key>
<string>com.docker.docker-machine</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/docker-machine</string>
<string>start</string>
<string>docker-vm</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

Add to .zshrc or .bashrc so the environment settings are loaded (DOCKER_HOST, etc.)

eval "$(docker-machine env docker-vm)"

Note you don't need to give the .plist file 'root' ownership, as scripts inside ~/Library/LaunchAgents are under 'user' ownership.

setup

cp com.docker.docker-machine.plist ~/Library/LaunchAgents
launchctl load com.docker.docker-machine.plist

start deliberately

launchctl start com.docker.docker-machine.plist

check running

docker-machine ls

uninstall

launchctl unload com.docker.docker-machine.plist
@chusiang
Copy link
Author

It's not work for me, so I create a rc.local.app with Apple Script Editor and add it to Login Items.

do shell script "
PATH='/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/Users/jonny/bin'

# Docker
/usr/local/bin/docker-machine start docker-vm

"

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