tl; dr It is easier to run Docker in a virtual virtual machine, either by creating a regular virtual machine, or using docker-machine . Then install the virtual machine to start at boot
Docker for mac
The Docker for Mac application creates the launch service:
ββ launchctl list | grep -i docker - 0 com.docker.helper 78105 0 com.docker.docker.52512
The service has the following data:
ββ launchctl list com.docker.docker.52512 { "LimitLoadToSessionType" = "Aqua"; "Label" = "com.docker.docker.52512"; "TimeOut" = 30; "OnDemand" = true; "LastExitStatus" = 0; "PID" = 78105; "Program" = "/Applications/Docker.app/Contents/MacOS/Docker"; "ProgramArguments" = ( "/Applications/Docker.app/Contents/MacOS/Docker"; ); "PerJobMachServices" = { "com.apple.tsm.portname" = mach-port-object; "com.apple.CFPasteboardClient" = mach-port-object; "com.apple.coredrag" = mach-port-object; "com.apple.axserver" = mach-port-object; }; };
And it has the following process tree:
ββ pstree -p 78105 -+= 00001 root /sbin/launchd \-+= 78105 matt /Applications/Docker.app/Contents/MacOS/Docker \-+= 78118 matt /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0 -max-restarts 5 -restart-seconds 30 |--- 78119 matt /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0 -max-restarts 5 -restart-seconds 30 |--= 78120 matt com.docker.db --url fd://3 --git /Users/matt/Library/Containers/com.docker.docker/Data/database |--= 78121 matt com.docker.osxfs --address fd:3 --connect /Users/matt/Library/Containers/com.docker.docker/Data/@connect --control fd:4 --volume-control |--= 78122 matt com.docker.slirp --db /Users/matt/Library/Containers/com.docker.docker/Data/s40 --ethernet fd:3 --port fd:4 --introspection fd:5 --diagn |-+= 78123 matt com.docker.osx.hyperkit.linux | \--- 78125 matt /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux \-+= 78124 matt com.docker.driver.amd64-linux -db /Users/matt/Library/Containers/com.docker.docker/Data/s40 -osxfs-volume /Users/matt/Library/Containers |--- 78126 matt /Applications/Docker.app/Contents/MacOS/com.docker.driver.amd64-linux -db /Users/matt/Library/Containers/com.docker.docker/Data/s40 -o \--- 78130 matt /Applications/Docker.app/Contents/MacOS/com.docker.hyperkit -A -m 2048M -c 3 -u -s 0:0,hostbridge -s 31,lpc -s 2:0,virtio-vpnkit,uuid=
The first problem is /Applications/Docker.app/Contents/MacOS/Docker - this is the GUI application that is in your tray, not the virtual machine, so it will be difficult to start at boot time. The first descendant of /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux more like managing a virtual machine, so we'll start there.
Get the full hyperkit process command
ββ ps -fp 78105 UID PID PPID C STIME TTY TIME CMD 501 78105 82644 0 2:08am ?? 0:00.03 /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0 -max-restarts 5 -restart-seconds 30
Get process working directory
ββ sudo lsof -p 78105 | grep cwd com.docke 78105 matt cwd DIR 1,4 748 63186601 /Users/matt/Library/Containers/com.docker.docker/Data
Create a launch /Library/LaunchDaemons/com.you.docker.plist file /Library/LaunchDaemons/com.you.docker.plist containing information
<?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.you.docker</string> <key>ProgramArguments</key> <array> <string>/Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux</string> <string>-watchdog</string> <string>fd:0</string> <string>-max-restarts</string> <string>5</string> <string>-restart-seconds</string> <string>30</string> </array> <key>UserName</key> <string>youruser</string> <key>WorkingDirectory</key> <string>/Users/youruser/Library/Containers/com.docker.docker/Data</string> <key>RunAtLoad</key> <true/> </dict> </plist>
What you can download with
sudo launchctl load -w /Library/LaunchDaemons/com.you.docker.plist
Then ... nothing. Check logs
ββ tail /var/log/system.log Mar 7 02:23:26 mac Docker[87728]: Acquired task manager lock Mar 7 02:23:26 mac Docker[87728]: Maximum number of file descriptors is 10240 Mar 7 02:23:26 mac Docker[87728]: Failed to read watchdog handshake Mar 7 02:23:26 mac com.apple.xpc.launchd[1] (com.you.docker[87728]): Service exited with abnormal code: 1
You will notice that the command we run indicates the -watchdog fd:0 option, which will be the stdin the hyperkit process, so maybe something is missing.
If I run Docker again and see what FD 0 is for the hyperkit process when it works
ββ sudo lsof -p 88360 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME com.docke 88360 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51
Then, by looking at PIPE 0xff80ce577ca2ed91 on the system, you will see that the main Docker process has a channel open to many processes.
ββ sudo lsof | grep 0xff80ce577ca2ed91 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Docker 88349 matt 13 PIPE 0xff80ce5776aa8d51 16384 ->0xff80ce577ca2ed91 com.docke 88360 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51 com.docke 88362 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51 com.docke 88363 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51 com.docke 88364 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51 com.docke 88365 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51 com.docke 88366 matt 0 PIPE 0xff80ce577ca2ed91 16384 ->0xff80ce5776aa8d51
Attempting to load the service again without the -watchdog fd:0 parameters results in the same error.
So, it seems that the main Docker application is doing some of the setup necessary to start the virtual machine. I could not find the source code for any transactions with the watchdog option, so I'm not sure what it expects.
There may be a problem or feature request at https://github.com/docker/for-mac to get information about starting a stand-alone virtual machine from an application.