Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrissearle/2c7911fbecd2225776a678d06bf16295 to your computer and use it in GitHub Desktop.
Save chrissearle/2c7911fbecd2225776a678d06bf16295 to your computer and use it in GitHub Desktop.
[How to start Colima automatically on macOS] Instructions for starting Colima automatically on macOS similar to Docker Desktop #macos #colima #docker

Steps

  1. Allow colima start to run without password:
cat <<-EOF | sudo tee /private/etc/sudoers.d/colima
%admin ALL=NOPASSWD: /bin/rm -rf /var/run/docker.sock
%admin ALL=NOPASSWD: /bin/ln -s $HOME/.colima/docker.sock /var/run/docker.sock
EOF
  1. Create an executable script to run in foreground and manage colima:
cat <<-EOF | sudo tee /usr/local/bin/colima-start-fg
#!/bin/bash

set -e

export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

function shutdown() {
  colima stop
  exit 0
}

trap shutdown SIGTERM
trap shutdown SIGKILL
trap shutdown SIGINT

colima start
tail -f /dev/null &
wait \$!
EOF

sudo chmod +x /usr/local/bin/colima-start-fg
  1. Create a launchd agent to run colima automatically:
cat > $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist <<-EOF
<?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.github.abiosoft.colima</string>
    <key>Program</key>
    <string>/usr/local/bin/colima-start-fg</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
  </dict>
</plist>
EOF

launchctl load -w $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment