-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
[Bug]: Unable to share host port in Mac #2570
Comments
cc @lbroudoux ❤️ |
@JulienBreux I see connections to the docker daemon to a TCP address:
Could it be possible that you switched from Testcontainers Cloud, which writes to the testcontainers properties file a TCP remote docker host, to plain Docker Desktop (or alternative) without using the Testcontainers Desktop app (which uses the |
I have expericed something similar when I was testing host ports. I think the problem is hardcoded testcontainers-go/port_forwarding.go Line 230 in bca5a28
I was able to fix my problem by changing testcontainers-go/wait/host_port.go Line 83 in bca5a28
And I think that the ssh container should idealy set testcontainers-go/port_forwarding.go Lines 153 to 158 in bca5a28
|
It's weird, as I'm on a Mac too and I do not see this error. Could you share more about your scenario if possible? |
For me a simple:
Docker Desktop |
I think that interface/ip address which used for exposed ports (in this case ssh port) is configurable in docker and is not guaranteed that it will be localhost on every system. |
I'm still facing the same issue with $ go test -timeout 60s -run ^TestExposeHostPorts$ github.com/testcontainers/testcontainers-go -v
=== RUN TestExposeHostPorts
=== RUN TestExposeHostPorts/single_port
2024/07/23 14:07:15 🐳 Creating container for image testcontainers/ryuk:0.8.1
2024/07/23 14:07:16 ✅ Container created: 4c138984352b
2024/07/23 14:07:16 🐳 Starting container: 4c138984352b
2024/07/23 14:07:16 ✅ Container started: 4c138984352b
2024/07/23 14:07:16 ⏳ Waiting for container id 4c138984352b image: testcontainers/ryuk:0.8.1. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/07/23 14:07:16 🔔 Container is ready: 4c138984352b
2024/07/23 14:07:16 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/07/23 14:07:16 ✅ Container created: a0870f18640a
2024/07/23 14:07:16 🐳 Starting container: a0870f18640a
2024/07/23 14:07:16 ✅ Container started: a0870f18640a
2024/07/23 14:07:16 🔔 Container is ready: a0870f18640a
2024/07/23 14:07:16 🐳 Creating container for image alpine:3.17
2024/07/23 14:07:16 ✅ Container created: 4ae584788dd7
2024/07/23 14:07:16 🐳 Starting container: 4ae584788dd7
2024/07/23 14:07:16 ✅ Container started: 4ae584788dd7
2024/07/23 14:07:16 🔔 Container is ready: 4ae584788dd7
2024/07/23 14:07:16 🐳 Terminating container: 4ae584788dd7
2024/07/23 14:07:16 🐳 Terminating container: a0870f18640a
2024/07/23 14:07:16 🚫 Container terminated: a0870f18640a
2024/07/23 14:07:17 🚫 Container terminated: 4ae584788dd7
=== RUN TestExposeHostPorts/single_port_using_a_network
port_forwarding_test.go:112: failed to expose host ports: failed to get the network: failed to list networks: Cannot connect to the Docker daemon at tcp://127.0.0.1:51636. Is the docker daemon running?: failed to create container
=== RUN TestExposeHostPorts/multiple_ports
2024/07/23 14:07:17 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/07/23 14:07:17 ✅ Container created: 07934e50c602
2024/07/23 14:07:17 🐳 Starting container: 07934e50c602
2024/07/23 14:07:17 ✅ Container started: 07934e50c602
2024/07/23 14:07:17 🔔 Container is ready: 07934e50c602
2024/07/23 14:07:17 🐳 Creating container for image alpine:3.17
2024/07/23 14:07:17 ✅ Container created: 9d3b2ef3fd10
2024/07/23 14:07:17 🐳 Starting container: 9d3b2ef3fd10
2024/07/23 14:07:17 ✅ Container started: 9d3b2ef3fd10
2024/07/23 14:07:17 🔔 Container is ready: 9d3b2ef3fd10
2024/07/23 14:07:17 🐳 Terminating container: 9d3b2ef3fd10
2024/07/23 14:07:17 🐳 Terminating container: 07934e50c602
2024/07/23 14:07:17 🚫 Container terminated: 07934e50c602
2024/07/23 14:07:17 🚫 Container terminated: 9d3b2ef3fd10
=== RUN TestExposeHostPorts/single_port_with_cancellation
2024/07/23 14:07:17 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/07/23 14:07:17 ✅ Container created: b4dbdc85c12f
2024/07/23 14:07:17 🐳 Starting container: b4dbdc85c12f
2024/07/23 14:07:17 ✅ Container started: b4dbdc85c12f
2024/07/23 14:07:17 🔔 Container is ready: b4dbdc85c12f
2024/07/23 14:07:17 🐳 Creating container for image alpine:3.17
2024/07/23 14:07:17 ✅ Container created: 5f6d4afe4753
2024/07/23 14:07:17 🐳 Starting container: 5f6d4afe4753
2024/07/23 14:07:18 ✅ Container started: 5f6d4afe4753
2024/07/23 14:07:18 🔔 Container is ready: 5f6d4afe4753
2024/07/23 14:07:29 🐳 Terminating container: 5f6d4afe4753
2024/07/23 14:07:29 🐳 Terminating container: b4dbdc85c12f
2024/07/23 14:07:29 🚫 Container terminated: b4dbdc85c12f
2024/07/23 14:07:29 🚫 Container terminated: 5f6d4afe4753
--- FAIL: TestExposeHostPorts (13.48s)
--- PASS: TestExposeHostPorts/single_port (1.12s)
--- FAIL: TestExposeHostPorts/single_port_using_a_network (0.09s)
--- PASS: TestExposeHostPorts/multiple_ports (0.67s)
--- PASS: TestExposeHostPorts/single_port_with_cancellation (11.60s)
FAIL
FAIL github.com/testcontainers/testcontainers-go 13.993s
FAIL
$ uname -a
Darwin MacBook-Pro-de-Laurent-2.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020 arm64 |
I have found out that our setup runs in containers which are accesing host docker daemon using mounted socket (something like |
I think #2403 tries to address that. |
I think this is now OK with a fresh $ go test -timeout 60s -run ^TestExposeHostPorts$ github.com/testcontainers/testcontainers-go -v
go: downloading github.com/docker/docker v27.1.1+incompatible
=== RUN TestExposeHostPorts
=== RUN TestExposeHostPorts/single_port
2024/09/04 14:30:26 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 24.0.2
API Version: 1.43
Operating System: Docker Desktop
Total Memory: 11962 MB
Testcontainers for Go Version: v0.34.0
Resolved Docker Host: unix:///var/run/docker.sock
Resolved Docker Socket Path: /var/run/docker.sock
Test SessionID: 3c51c5001b926adaaced72a4a825b61c3ebffe7f1b3ad54807d578681ea4072d
Test ProcessID: 08686ed6-b490-4bc1-9362-863b409b46d6
2024/09/04 14:30:27 Failed to get image auth for https://index.docker.io/v1/. Setting empty credentials for the image: testcontainers/ryuk:0.9.0. Error is: credentials not found in native keychain
2024/09/04 14:30:29 🐳 Creating container for image testcontainers/ryuk:0.9.0
2024/09/04 14:30:30 ✅ Container created: ab05786adcf0
2024/09/04 14:30:30 🐳 Starting container: ab05786adcf0
2024/09/04 14:30:30 ✅ Container started: ab05786adcf0
2024/09/04 14:30:30 ⏳ Waiting for container id ab05786adcf0 image: testcontainers/ryuk:0.9.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms skipInternalCheck:false}
2024/09/04 14:30:30 🔔 Container is ready: ab05786adcf0
2024/09/04 14:30:30 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/09/04 14:30:30 ✅ Container created: 7ea81f499603
2024/09/04 14:30:30 🐳 Starting container: 7ea81f499603
2024/09/04 14:30:30 ✅ Container started: 7ea81f499603
2024/09/04 14:30:31 ⏳ Waiting for container id 7ea81f499603 image: testcontainers/sshd:1.2.0. Waiting for: &{Port:22/tcp timeout:<nil> PollInterval:100ms skipInternalCheck:false}
2024/09/04 14:30:31 🔔 Container is ready: 7ea81f499603
2024/09/04 14:30:31 🐳 Creating container for image alpine:3.17
2024/09/04 14:30:31 ✅ Container created: 1282a054ff3e
2024/09/04 14:30:31 🐳 Starting container: 1282a054ff3e
2024/09/04 14:30:31 ✅ Container started: 1282a054ff3e
2024/09/04 14:30:31 🔔 Container is ready: 1282a054ff3e
2024/09/04 14:30:31 🐳 Terminating container: 1282a054ff3e
2024/09/04 14:30:31 🐳 Terminating container: 7ea81f499603
2024/09/04 14:30:31 🚫 Container terminated: 7ea81f499603
2024/09/04 14:30:31 🚫 Container terminated: 1282a054ff3e
=== RUN TestExposeHostPorts/single_port_using_a_network
2024/09/04 14:30:31 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/09/04 14:30:31 ✅ Container created: 739aac57801c
2024/09/04 14:30:31 🐳 Starting container: 739aac57801c
2024/09/04 14:30:31 ✅ Container started: 739aac57801c
2024/09/04 14:30:31 ⏳ Waiting for container id 739aac57801c image: testcontainers/sshd:1.2.0. Waiting for: &{Port:22/tcp timeout:<nil> PollInterval:100ms skipInternalCheck:false}
2024/09/04 14:30:32 🔔 Container is ready: 739aac57801c
2024/09/04 14:30:32 🐳 Creating container for image alpine:3.17
2024/09/04 14:30:32 ✅ Container created: 833b847b07d3
2024/09/04 14:30:32 🐳 Starting container: 833b847b07d3
2024/09/04 14:30:32 ✅ Container started: 833b847b07d3
2024/09/04 14:30:32 🔔 Container is ready: 833b847b07d3
2024/09/04 14:30:32 🐳 Terminating container: 833b847b07d3
2024/09/04 14:30:32 🐳 Terminating container: 739aac57801c
2024/09/04 14:30:32 🚫 Container terminated: 739aac57801c
2024/09/04 14:30:32 🚫 Container terminated: 833b847b07d3
=== RUN TestExposeHostPorts/multiple_ports
2024/09/04 14:30:32 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/09/04 14:30:32 ✅ Container created: 20c901dd98b7
2024/09/04 14:30:32 🐳 Starting container: 20c901dd98b7
2024/09/04 14:30:32 ✅ Container started: 20c901dd98b7
2024/09/04 14:30:32 ⏳ Waiting for container id 20c901dd98b7 image: testcontainers/sshd:1.2.0. Waiting for: &{Port:22/tcp timeout:<nil> PollInterval:100ms skipInternalCheck:false}
2024/09/04 14:30:32 🔔 Container is ready: 20c901dd98b7
2024/09/04 14:30:32 🐳 Creating container for image alpine:3.17
2024/09/04 14:30:33 ✅ Container created: a6d77527d929
2024/09/04 14:30:33 🐳 Starting container: a6d77527d929
2024/09/04 14:30:33 ✅ Container started: a6d77527d929
2024/09/04 14:30:33 🔔 Container is ready: a6d77527d929
2024/09/04 14:30:33 🐳 Terminating container: a6d77527d929
2024/09/04 14:30:33 🐳 Terminating container: 20c901dd98b7
2024/09/04 14:30:33 🚫 Container terminated: 20c901dd98b7
2024/09/04 14:30:33 🚫 Container terminated: a6d77527d929
=== RUN TestExposeHostPorts/single_port_with_cancellation
2024/09/04 14:30:33 🐳 Creating container for image testcontainers/sshd:1.2.0
2024/09/04 14:30:33 ✅ Container created: 5db600520bf0
2024/09/04 14:30:33 🐳 Starting container: 5db600520bf0
2024/09/04 14:30:33 ✅ Container started: 5db600520bf0
2024/09/04 14:30:33 ⏳ Waiting for container id 5db600520bf0 image: testcontainers/sshd:1.2.0. Waiting for: &{Port:22/tcp timeout:<nil> PollInterval:100ms skipInternalCheck:false}
2024/09/04 14:30:33 🔔 Container is ready: 5db600520bf0
2024/09/04 14:30:33 🐳 Creating container for image alpine:3.17
2024/09/04 14:30:33 ✅ Container created: 5d2afc6f6fa5
2024/09/04 14:30:33 🐳 Starting container: 5d2afc6f6fa5
2024/09/04 14:30:34 ✅ Container started: 5d2afc6f6fa5
2024/09/04 14:30:34 🔔 Container is ready: 5d2afc6f6fa5
2024/09/04 14:30:45 🐳 Terminating container: 5d2afc6f6fa5
2024/09/04 14:30:45 🐳 Terminating container: 5db600520bf0
2024/09/04 14:30:45 🚫 Container terminated: 5db600520bf0
2024/09/04 14:30:45 🚫 Container terminated: 5d2afc6f6fa5
--- PASS: TestExposeHostPorts (18.87s)
--- PASS: TestExposeHostPorts/single_port (5.12s)
--- PASS: TestExposeHostPorts/single_port_using_a_network (0.98s)
--- PASS: TestExposeHostPorts/multiple_ports (0.87s)
--- PASS: TestExposeHostPorts/single_port_with_cancellation (11.89s)
PASS
ok github.com/testcontainers/testcontainers-go 19.328s @mdelapenya Could you confirm this is expected and maybe a collateral effect of #2403? @JulienBreux Could you confirm this is fixed and that we can proceed on microcks/microcks-testcontainers-go#12? Thanks guys! |
Testcontainers version
0.31.0
Using the latest Testcontainers version?
Yes
Host OS
macOS Sonoma 14.5
Host arch
ARM
Go version
1.22.4
Docker version
Client: Cloud integration: v1.0.35+desktop.13 Version: 26.1.1 API version: 1.45 Go version: go1.21.9 Git commit: 4cf5afa Built: Tue Apr 30 11:44:56 2024 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.30.0 (149282) Engine: Version: 26.1.1 API version: 1.45 (minimum version 1.24) Go version: go1.21.9 Git commit: ac2de55 Built: Tue Apr 30 11:48:04 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.31 GitCommit: e377cd56a71523140ca6ae87e30244719194a521 runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0
Docker info
What happened?
Just run
/usr/local/go/bin/go test -timeout 60s -run ^TestExposeHostPorts$ github.com/testcontainers/testcontainers-go -v
Relevant log output
Additional information
No response
The text was updated successfully, but these errors were encountered: