|
| 1 | +# Using a Docker Desktop for Mac as a client for the proxy (stable version) |
| 2 | + |
| 3 | +First, know this is a MiTM, and could break with new Docker Desktop for Mac releases or during resets/reinstalls/upgrades. |
| 4 | + |
| 5 | +These instructions tested on Mac OS Catalina, and: |
| 6 | +- Docker Desktop for Mac `2.5.0.0` (Stable) (which provides Docker `19.03`) |
| 7 | +- Docker Desktop for Mac `2.4.2.0` (Edge) (which provides Docker `20.10.0-beta1`) |
| 8 | + |
| 9 | +This assumes you have `docker-registry-proxy` running _somewhere else_, eg, on a different machine on your local network. |
| 10 | + |
| 11 | +See the main [README.md](README.md) for instructions. (If you're trying to run both proxy and client on the same machine, see below). |
| 12 | + |
| 13 | +For these examples I will assume it is successfully running on `http://192.168.1.2:3128/` |
| 14 | + |
| 15 | +- Make sure you can access the proxy. On your Mac/Terminal (not Docker), run: |
| 16 | + ```shell script |
| 17 | + # with wget... |
| 18 | + wget --quiet -O - "http://192.168.1.2:3128/" |
| 19 | + # ... or, with curl: |
| 20 | + curl "http://192.168.1.2:3128/" |
| 21 | + ``` |
| 22 | +- Make sure your Docker Desktop for Mac install is pristine like new, go into Troubleshoot > "Reset to Factory defaults". |
| 23 | +- Inject the CA certificates into the Docker install inside the HyperKit VM running LinuxKit that is used by Docker Desktop for Mac. |
| 24 | + To do that, we use a privileged container. `justincormack/nsenter1` does the job nicely: |
| 25 | + ```shell script |
| 26 | + docker run -it --privileged --pid=host justincormack/nsenter1 /bin/bash -c "wget -O - http://192.168.1.2:3128/ca.crt | tee -a /containers/services/docker/lower/etc/ssl/certs/ca-certificates.crt" |
| 27 | + ``` |
| 28 | +- Go into `Docker > Preferences`, and set `Resources > Proxies` to |
| 29 | + - "Manual proxy configuration" to ON |
| 30 | + - HTTP proxy: `http://192.168.1.2:3128/` |
| 31 | + - HTTPS proxy: `http://192.168.1.2:3128/` |
| 32 | + - (Optional) I also recommend "Enable CLI experimental features" under "Experimental Features" (since I use `buildx` a lot) |
| 33 | + - Click button "Apply & Restart", wait for it to restart. |
| 34 | +- Try a `docker pull` now. It should be using the proxy (watch the logs on the proxy server). |
| 35 | +- Important: **push**es done with this configured will either not work, or use the auth you configured on the proxy, if any. Beware, and report back. |
| 36 | + |
| 37 | + |
| 38 | +# Using Docker Desktop for Mac to both host the proxy server and use it as a client |
| 39 | + |
| 40 | +@TODO: This has a bunch of chicken-and-egg issues. |
| 41 | + |
| 42 | +You need to pre-pull the proxy itself and `justincormack/nsenter1`. |
| 43 | + |
| 44 | +Then set up the proxy server, and then follow the instructions above (without the Factory Reset). |
| 45 | + |
| 46 | +Do NOT use 127.0.0.1, instead use your machine's local LAN IP address. (Hint: there's a good chance 192.168.64.1 is useable, due the the way Docker Desktop for Mac sets networking up). |
| 47 | + |
| 48 | +Make sure to bring the proxy up after applying/restarting the Docker Engine. |
0 commit comments