Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. bobziuchkovski revised this gist Aug 28, 2023. 1 changed file with 5 additions and 9 deletions.
    14 changes: 5 additions & 9 deletions how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,9 @@
    ## Steps

    1. Create an executable script to run in foreground and manage colima:

    ```bash
    # Create launcher script
    cat <<-EOF | sudo tee /usr/local/bin/colima-start-fg
    #!/bin/bash
    export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export PATH="/opt/homebrew/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    function shutdown() {
    colima stop
    @@ -31,12 +28,10 @@ tail -f /dev/null &
    wait \$!
    EOF

    # Mark script executable
    sudo chmod +x /usr/local/bin/colima-start-fg
    ```

    2. Create a launchd agent to run **colima** automatically:

    ```bash
    # Create launch agent
    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">
    @@ -54,5 +49,6 @@ cat > $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist <<-EOF
    </plist>
    EOF

    # Load the launch agent
    launchctl load -w $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist
    ```
  2. @fardjad fardjad revised this gist Jul 8, 2023. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,6 @@ function shutdown() {
    }
    trap shutdown SIGTERM
    trap shutdown SIGKILL
    trap shutdown SIGINT
    # wait until colima is running
  3. @fardjad fardjad revised this gist Mar 20, 2023. 1 changed file with 11 additions and 3 deletions.
    14 changes: 11 additions & 3 deletions how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,6 @@
    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() {
    @@ -19,7 +17,17 @@ trap shutdown SIGTERM
    trap shutdown SIGKILL
    trap shutdown SIGINT
    colima start
    # wait until colima is running
    while true; do
    colima status &>/dev/null
    if [[ \$? -eq 0 ]]; then
    break;
    fi
    colima start
    sleep 5
    done
    tail -f /dev/null &
    wait \$!
    EOF
  4. @fardjad fardjad revised this gist Mar 20, 2023. 1 changed file with 2 additions and 11 deletions.
    13 changes: 2 additions & 11 deletions how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,6 @@
    ## Steps

    1. Allow `colima start` to run without password:

    ```bash
    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
    ```

    2. Create an executable script to run in foreground and manage colima:
    1. Create an executable script to run in foreground and manage colima:

    ```bash
    cat <<-EOF | sudo tee /usr/local/bin/colima-start-fg
    @@ -36,7 +27,7 @@ EOF
    sudo chmod +x /usr/local/bin/colima-start-fg
    ```

    3. Create a launchd agent to run **colima** automatically:
    2. Create a launchd agent to run **colima** automatically:

    ```bash
    cat > $HOME/Library/LaunchAgents/com.github.abiosoft.colima.plist <<-EOF
  5. @fardjad fardjad revised this gist Apr 3, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ trap shutdown SIGINT
    colima start
    tail -f /dev/null &
    wait $!
    wait \$!
    EOF

    sudo chmod +x /usr/local/bin/colima-start-fg
  6. @fardjad fardjad revised this gist Apr 3, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    1. Allow `colima start` to run without password:

    ```bash
    cat <-EOF | sudo tee /private/etc/sudoers.d/colima
    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
    @@ -12,7 +12,7 @@ EOF
    2. Create an executable script to run in foreground and manage colima:

    ```bash
    cat <-EOF | sudo tee /usr/local/bin/colima-start-fg
    cat <<-EOF | sudo tee /usr/local/bin/colima-start-fg
    #!/bin/bash
    set -e
  7. @fardjad fardjad created this gist Apr 3, 2022.
    60 changes: 60 additions & 0 deletions how-to-start-colima-automatically-on-macos.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    ## Steps

    1. Allow `colima start` to run without password:

    ```bash
    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
    ```

    2. Create an executable script to run in foreground and manage colima:

    ```bash
    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
    ```

    3. Create a launchd agent to run **colima** automatically:

    ```bash
    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
    ```