use-colima.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. echo "Stopping Docker.app. You may ignore a 'process terminated unexpectedly' dialog."
  3. osascript - <<'EOF' || exit
  4. tell application "Docker"
  5. if it is running then quit it
  6. end tell
  7. EOF
  8. # We aren't uninstalling for now - this makes rolling back to docker desktop faster.
  9. # Also, less breakage as people may be using things like docker-credential-desktop.
  10. # echo "Uninstalling docker cask (which includes Docker Desktop)."
  11. # brew uninstall --cask docker
  12. # We do want to get people on just the docker cli though, to enable uninstalling the cask.
  13. echo "Installing docker (cli only)."
  14. brew install docker
  15. # Unlinks docker (cask).
  16. brew unlink docker
  17. brew link --overwrite docker
  18. # This removes credsStore, saving it under oldCredsStore so it can be restored later.
  19. # The right value under colima for this is "colima", but I think vast majority of people
  20. # are authing their docker through gcloud, not docker cli.
  21. python3 <<'EOF'
  22. import os
  23. import json
  24. with open(os.path.expanduser("~/.docker/config.json"), "rb") as f:
  25. config = json.loads(f.read())
  26. credsStore = config.get("credsStore")
  27. if credsStore is None:
  28. exit(0)
  29. config["oldCredsStore"] = credsStore
  30. del config["credsStore"]
  31. with open(os.path.expanduser("~/.docker/config.json"), "w") as f:
  32. f.write(json.dumps(config))
  33. EOF
  34. echo "Installing colima."
  35. brew install colima
  36. brew link colima