Commit b9ec333
committed
feat: Add support for Docker Desktop socket locations on macOS
Docker Desktop for macOS v4.x+ changed the default socket location from
/var/run/docker.sock to ~/.docker/run/docker.sock. This caused
ConnectionError/FileNotFoundError when users didn't have DOCKER_HOST set.
This commit adds automatic socket discovery that checks multiple locations
in order of preference:
1. /var/run/docker.sock (traditional Linux/macOS location)
2. ~/.docker/run/docker.sock (Docker Desktop v4.x+ on macOS)
3. ~/.docker/desktop/docker.sock (older Docker Desktop location)
The implementation:
- Adds UNIX_SOCKET_PATHS list with known socket locations
- Adds _find_available_unix_socket() function for discovery
- Makes DEFAULT_UNIX_SOCKET dynamically computed at import time
- Falls back to /var/run/docker.sock if no socket exists
This only affects Unix/macOS; Windows continues to use named pipes.
DOCKER_HOST environment variable and Docker contexts still take precedence.
Fixes #32711 parent df3f8e2 commit b9ec333
3 files changed
Lines changed: 252 additions & 247 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
15 | 35 | | |
16 | 36 | | |
17 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
| 94 | + | |
92 | 95 | | |
93 | 96 | | |
94 | | - | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| |||
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
| 131 | + | |
| 132 | + | |
128 | 133 | | |
129 | 134 | | |
130 | | - | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
| 206 | + | |
| 207 | + | |
201 | 208 | | |
202 | 209 | | |
203 | | - | |
| 210 | + | |
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
| |||
233 | 240 | | |
234 | 241 | | |
235 | 242 | | |
| 243 | + | |
| 244 | + | |
236 | 245 | | |
237 | 246 | | |
238 | | - | |
| 247 | + | |
239 | 248 | | |
240 | 249 | | |
241 | 250 | | |
| |||
0 commit comments