Docker for Mac does not respect the DOCKER_CONFIG
var - docker/for-mac#2635
However, using launchctl
you can get the desktop app to use a different .docker
location.
- Create a plist file, I use
environment.plist
as I use this workaround for other apps. - Insert the following into the plist file:
<?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>my.startup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>
launchctl setenv DOCKER_CONFIG /Users/myuser/.config/docker
</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
- Move the file to the LaunchAgents folder (optional, but recommended)
mv environment.plist ~/Library/LaunchAgents/
- Start the agent
launchctl start ~/Library/LaunchAgents/environment.plist
Now, when you open Docker (or any other app!), the DOCKER_CONFIG
variable will be set to the value you provide, and Docker will use the proper path for the config.