Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker socket in docker agent on windows (docker in docker) #5657

Merged
merged 4 commits into from Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions changes/pr5657.yaml
@@ -0,0 +1,6 @@

fix:
- "Fix docker-in-docker issue in DockerAgent on windows - [#5657](https://github.com/PrefectHQ/prefect/pull/5657)"

contributor:
- "[limx0](https://github.com/limx0)"
11 changes: 8 additions & 3 deletions src/prefect/agent/docker/agent.py
Expand Up @@ -265,9 +265,14 @@ def _parse_volume_spec_win32(
external = ntpath.normpath(fields[0])
internal = posixpath.normpath(fields[1])
elif len(fields) == 1:
# \path1 <-- assumed container path of /path1 (relative to current drive)
external = ntpath.normpath(fields[0])
internal = external
if fields[0] == "//var/run/docker.sock":
# Special handling for docker-in-docker
external = "//var/run/docker.sock"
internal = "/var/run/docker.sock"
else:
# \path1 <-- assumed container path of /path1 (relative to current drive)
external = ntpath.normpath(fields[0])
internal = external
else:
raise ValueError(
"Unable to parse volume specification '{}'".format(volume_spec)
Expand Down
7 changes: 7 additions & 0 deletions tests/agent/test_docker_agent.py
Expand Up @@ -947,6 +947,13 @@ def test_docker_agent_parse_volume_spec_unix(
["/c/some/path"],
{"C:\\some\\path": {"bind": "/c/some/path", "mode": "rw"}},
),
(
# windows docker socket
["//var/run/docker.sock"],
[],
["/var/run/docker.sock"],
{"//var/run/docker.sock": {"bind": "/var/run/docker.sock", "mode": "rw"}},
),
(
# internal & external paths
["C:\\some\\path:/ctr/path"],
Expand Down