Skip to content

Commit 5018486

Browse files
an-kyphilpep
authored andcommitted
Workaround Docker#42442 by using IPv4 SSH only
As described in moby/moby#42442, docker daemon starts to expose a container port on different host ports for IPv4 and IPv6 which breaks the ssh/safe-ssh/ansible backend tests for some containers. To prevent this behavior and flaky tests, only the first line from the `docker port %s 22` command gets parsed to acquire the mapped SSH port.
1 parent ca0f8bd commit 5018486

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ def teardown():
113113
request.addfinalizer(teardown)
114114

115115
port = check_output("docker port %s 22", docker_id)
116-
port = int(port.rsplit(":", 1)[-1])
116+
# IPv4 addresses seem to be reported consistently
117+
# in the first line of the output.
118+
# To workaround https://github.com/moby/moby/issues/42442
119+
# use only the values of the first line of the command
120+
# output
121+
port = int(port.splitlines()[0].rsplit(":", 1)[-1])
122+
117123
return docker_id, docker_host, port
118124

119125
fname = "_docker_container_{}_{}".format(image, scope)

0 commit comments

Comments
 (0)