I have a docker-machine
called default
. I am trying to get it to start upon boot. I can do it upon log in but I need it without having to log in.
I have put the following file in both /LaunchAgents/com.docker.machine.default.plist
and /LaunchDaemons/com.docker.machine.default.plist
, both of which aren't working.
/Library/LaunchDaemons/com.docker.machine.default.plist
<?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>RunAtLoad</key>
<true/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string>
</dict>
<key>Label</key>
<string>com.docker.machine.default</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/docker-machine</string>
<string>start</string>
<string>default</string>
</array>
</dict>
</plist>
I have also run sudo chmod 640
on both files in case there was a permission issue as described here .
When I run, sudo launchctl load -w com.docker.machine.default.plist
as described in the tutorial I get "service already loaded".
The service is definitely not running as I have checked using docker-machine ls
and docker-machine status default
and the machine is stopped on start up.
Update
I have added logging into my LaunchDaemon and get the following output.
Host does not exist: "default"
I then run docker-machine ls
and I get:
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Stopped Unknown
As you can see the machine is there. If I run docker-machine start default
manually, it starts up fine...
Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Services from /Library/LaunchDaemons by default run as root user. root have no any docker machines. You can specify user (jenkins in my case) as
<key>UserName</key>
<string>jenkins</string>
For more documentation you can use man launchd.plist
.
Full org.vovkasm.docker-machine.plist that I'am use for jenkins user:
<?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>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin</string>
</dict>
<key>Label</key>
<string>org.vovkasm.docker-machine</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/docker-machine/bin/docker-machine</string>
<string>start</string>
<string>default</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local</string>
<key>UserName</key>
<string>jenkins</string>
</dict>
</plist>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.