Open dfioravanti opened 7 months ago
Running into the same issue. The test I used to recreate the issue looks like:
import (
"context"
"testing"
"github.com/testcontainers/testcontainers-go"
)
func TestPodman(t *testing.T) {
ctx := context.Background()
_, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{}, // never evaluated ...
})
if err != nil {
t.Fatalf("could not start container: %v", err)
}
}
I'd expect it to fail with something hinting towards the image name being empty.
The output is
=== RUN TestPodman
2024/04/17 12:04:54 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 5.0.1
API Version: 1.41
Operating System: fedora
Total Memory: 1952 MB
Resolved Docker Host: unix:///var/run/docker.sock
Resolved Docker Socket Path: /var/run/docker.sock
Test SessionID: 748e590ad3a32566931082a26236b0bed5703256a2a60b218eb5f4bfd72a9b76
Test ProcessID: 6986206b-fbed-4e04-8f4e-d2ba49e32112
2024/04/17 12:04:54 π³ Creating container for image testcontainers/ryuk:0.7.0
model_test.go:36: could not start container: Error response from daemon: container create: unable to find network with name or ID bridge: network not found: creating reaper failed: failed to create container
--- FAIL: TestPodman (0.09s)
=== RUN TestPodman
2024/04/17 12:04:54 π³ Creating container for image testcontainers/ryuk:0.7.0
podman_testcontainers_test.go:16: could not start container: Error response from daemon: container create: unable to find network with name or ID bridge: network not found: creating reaper failed: failed to create container
--- FAIL: TestPodman (0.01s)
FAIL
using Podman 5.0.1 here:
~> podman version
Client: Podman Engine
Version: 5.0.1
API Version: 5.0.1
Go Version: go1.22.1
Git Commit: 946d055df324e4ed6c1e806b561af4740db4fea9
Built: Mon Apr 1 13:28:31 2024
OS/Arch: darwin/arm64
Server: Podman Engine
Version: 5.0.1
API Version: 5.0.1
Go Version: go1.21.8
Built: Mon Apr 1 01:00:00 2024
OS/Arch: linux/arm64
I debugged a bit:
The current auto-detection of Podman looks for "podman.sock" within the socket name. This works with Podman on Linux, but when using podman-mac-helper
for MacOS, the socket name (on the host) is /var/run/docker.sock
. (https://github.com/testcontainers/testcontainers-go/blob/main/provider.go#L106)
Setting ProviderType
in the test code like this
_, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{}, // never evaluated ...
ProviderType: testcontainers.ProviderPodman,
})
fixes the network configuration issue. Also the PR https://github.com/testcontainers/testcontainers-go/pull/1990 addresses this with a global configuration option. However this has been stale for a bit.
Maybe the /info
or /version
calls could be scraped to detect the server is actually Podman instead.
I ran into this issue on a setup similar to the original poster.
@godart, I tried your fix, but I kept running into this issue:
2024/05/04 21:42:45 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 5.0.1
API Version: 1.41
Operating System: fedora
Total Memory: 3622 MB
Resolved Docker Host: unix:///var/run/docker.sock
Resolved Docker Socket Path: /var/run/docker.sock
Test SessionID: f9ea1ec477217d1ab405cd38e21e3a471f5360d6b852712ecd8c286ba9a5f9f2
Test ProcessID: 9043d990-9cb6-40d3-adf7-ba8d0381a833
2024/05/04 21:42:45 π³ Creating container for image testcontainers/ryuk:0.7.0
2024/05/04 21:42:45 β
Container created: 2b3afd5d2e60
2024/05/04 21:42:45 π³ Starting container: 2b3afd5d2e60
2024/05/04 21:42:45 β
Container started: 2b3afd5d2e60
2024/05/04 21:42:45 π§ Waiting for container id 2b3afd5d2e60 image: testcontainers/ryuk:0.7.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/05/04 21:42:45 container logs (unexpected container status "stopped"):
2024/05/04 19:42:45 Pinging Docker...
panic: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied
I even tried setting my DOCKER_HOST
to point to my podman socket with DOCKER_HOST=unix:///Users/user/.local/share/containers/podman/machine/podman.sock
which got rid of the permissions issue but still yielded an error:
2024/05/04 21:56:15 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 5.0.1
API Version: 1.41
Operating System: fedora
Total Memory: 3622 MB
Resolved Docker Host: unix:///Users/user/.local/share/containers/podman/machine/podman.sock
Resolved Docker Socket Path: /Users/user/.local/share/containers/podman/machine/podman.sock
Test SessionID: 64a4a58cee7888739aebd93541d7a4b0b0200d84a9b10f396a5c4148984f1601
Test ProcessID: 33aa8c36-5cdb-4b96-8725-b9539ef9c0d3
2024/05/04 21:56:15 π³ Creating container for image testcontainers/ryuk:0.7.0
--- FAIL: TestWithRedis (0.07s)
startup_test.go:23: Could not start redis: Error response from daemon: container create: statfs /Users/user/.local/share/containers/podman/machine/podman.sock: operation not supported: creating reaper failed: failed to create container
Did you not run into this issue?
We are having similar issues with colima
and rancher-desktop
2024/05/09 11:11:09 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 24.0.9
API Version: 1.43
Operating System: Ubuntu 23.10
Total Memory: 1895 MB
Resolved Docker Host: unix:///Users/mohsan.abbas/.colima/default/docker.sock
Resolved Docker Socket Path: /Users/mohsan.abbas/.colima/default/docker.sock
Test SessionID: c1729139638928699b678e3fdc7dfff4e56482cc2310ee2358a09f68931641e0
Test ProcessID: e4f04ff7-5395-48a9-be14-51c54e9af8df
2024/05/09 11:11:09 π³ Creating container for image testcontainers/ryuk:0.7.0
2024/05/09 11:11:09 β
Container created: 114d4680aa73
2024/05/09 11:11:09 π³ Starting container: 114d4680aa73
2024/05/09 11:11:09 β
Container started: 114d4680aa73
2024/05/09 11:11:09 π§ Waiting for container id 114d4680aa73 image: testcontainers/ryuk:0.7.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/05/09 11:11:09 failed accessing container logs: Error response from daemon: No such container: 114d4680aa73b82030172ccfe23cb81d4a7364beb7217e6fb2472cd716b0d055
--- FAIL: TestKafkaIntegration (0.57s)
kgo_test.go:182: Failed to start Kafka container: Error response from daemon: No such container: 114d4680aa73b82030172ccfe23cb81d4a7364beb7217e6fb2472cd716b0d055: could not start container: creating reaper failed: failed to create container
FAIL
Same here, tested with colima
and rancher-desktop
and ryuk fails to start (it exits as soon as it is started). Tested same code with Docker Desktop and it works OK.
It fails 95% of the times in my case.
Using testcontainers-go v0.31.0
2024/05/24 18:03:14 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 24.0.7
API Version: 1.43
Operating System: Alpine Linux v3.19
Total Memory: 3917 MB
Resolved Docker Host: unix:////Users/nicanor.romero/.rd/docker.sock
Resolved Docker Socket Path: //Users/nicanor.romero/.rd/docker.sock
Test SessionID: b20e559a2d29b918a349d7787d3b028fed79a1dae056e79c34e679e5e8532320
Test ProcessID: 7cb791c0-9fce-4843-9459-877e9a87f0a7
2024/05/24 18:03:14 π³ Creating container for image testcontainers/ryuk:0.7.0
2024/05/24 18:03:14 β
Container created: 9784e0df56ac
2024/05/24 18:03:14 π³ Starting container: 9784e0df56ac
2024/05/24 18:03:14 β
Container started: 9784e0df56ac
2024/05/24 18:03:14 π§ Waiting for container id 9784e0df56ac image: testcontainers/ryuk:0.7.0. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2024/05/24 18:03:14 failed accessing container logs: Error response from daemon: No such container: 9784e0df56ace89ed75bf6ff055fdef26c849382c5a69525f95a879f43ecd854
2024/05/24 18:03:14 Could not start redis: Error response from daemon: No such container: 9784e0df56ace89ed75bf6ff055fdef26c849382c5a69525f95a879f43ecd854: could not start container: creating reaper failed: failed to create container
I tried changing the version of ryuk but got the same results.
I debugged the process and found it fails here, between the CreateContainer
and the Start
.
Tested with the Quickstart example
I finally tracked my error to something between v0.13.0
(OK) and v0.14.0
. Debugging how ryuk containers where created I saw this diff among others:
"Mounts": [
{
"Type": "bind",
- "Source": "/var/run/docker.sock",
+ "Source": "/Users/nicanor.romero/.colima/docker.sock",
"Destination": "/var/run/docker.sock",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
I found 2 fixes (I prefer the first one):
Setting TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
env variable to /var/run/docker.sock
. I previously tried setting it to colima's docker.sock and it still failed. And keep your DOCKER_HOST
env variable as unix:////Users/$USER/.colima/docker.sock
with your particular user.
Linking the /var/run/docker.sock
to colima's docker.sock and removing the DOCKER_HOST
env variable that was pointing to colima.
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
I found 2 fixes (I prefer the first one):
- Setting
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
env variable to/var/run/docker.sock
. I previously tried setting it to colima's docker.sock and it still failed. And keep yourDOCKER_HOST
env variable asunix:////Users/$USER/.colima/docker.sock
with your particular user.- Linking the
/var/run/docker.sock
to colima's docker.sock and removing theDOCKER_HOST
env variable that was pointing to colima.sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
@nicanor-romero :
Option 1 is documented here https://golang.testcontainers.org/features/configuration/#docker-socket-path-detection, as part of the discovery mechanism.
And Option 2 is documented here: https://golang.testcontainers.org/system_requirements/using_colima/
@dfioravanti if you agree, I think we can close this one, but please keep it open if you see it's not resolved with the recent versions of the project.
Thanks!
Testcontainers version
0.28
Using the latest Testcontainers version?
Yes
Host OS
MacOs
Host arch
ARM
Go version
1.22
Docker version
Docker info
What happened?
I wanted to switch from docker-desktop to podman as docker provider on MacOs. Everything works but only if I disable ryuk. Otherwise testcontainer crashes at boot up with
Any idea how to fix this? I have tried everything that I can google, podman is run as rootful and the socket is correctly configured. Testcontainers with ryuk disabled works as expected but it would be nice if it would just work without requiring disabling it.
Relevant log output
No response
Additional information
I am using this project to trigger the issue in case you want to reproduce: https://github.com/dfioravanti/go-rest. Just run
go test ./...
in the root.