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

[Bug]: Test cannot connect to container spun up via compose module #1374

Open
n-tucker opened this issue Jul 31, 2023 · 1 comment
Open

[Bug]: Test cannot connect to container spun up via compose module #1374

n-tucker opened this issue Jul 31, 2023 · 1 comment
Labels
bug An issue with the library compose Docker Compose.

Comments

@n-tucker
Copy link

Testcontainers version

0.21.0

Using the latest Testcontainers version?

Yes

Host OS

Mac

Host arch

ARM

Go version

1.20.3

Docker version

Client:
 Cloud integration: v1.0.31
 Version:           23.0.5
 API version:       1.42
 Go version:        go1.19.8
 Git commit:        bc4487a
 Built:             Wed Apr 26 16:12:52 2023
 OS/Arch:           darwin/arm64
 Context:           default

Server: Docker Desktop 4.19.0 (106363)
 Engine:
  Version:          23.0.5
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       94d3ad6
  Built:            Wed Apr 26 16:17:14 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.3
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.19
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.4
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  v0.10.0
    Path:     /Users/nicholas.tucker/.docker/cli-plugins/docker-scout

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 4
 Server Version: 23.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: 8c325c45-1e53-4780-b05a-1c44ddcd3d31
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

Hello,

I've been trying to incorporate a testcontainers test in our CI platform. To do this, I'm attempting to run testcontainers within a docker container by running docker-outside-of-docker (as described in the docs here).

I'm encountering an issue using the compose module, as ideally we'd like to reuse our existing docker compose file. It appears that testcontainers can't connect to the container brought up. I've noticed that it creates its own network, so I'm wondering if the container isn't part of the same network as the golang container where I'm running testcontainers from?

Another reason why I think this might be a networking inconsistency with the compose module is if I convert my use of the compose module into a ContainerRequest, the test can connect to the target container without errors.

Thanks in advance for your help, and happy to provide more info if required!

Relevant log output

=== RUN   TestMain

**********************************************************************************************
Ryuk has been disabled for the current execution. This can cause unexpected behavior in your environment.
More on this: https://golang.testcontainers.org/features/garbage_collector/
**********************************************************************************************
2023/07/31 23:32:08 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 23.0.5
  API Version: 1.42
  Operating System: Docker Desktop
  Total Memory: 7951 MB
 Network end-to-end-test_default  Creating
 Network end-to-end-test_default  Created
 Container doomsday-notifications  Creating
 Container doomsday-notifications  Created
 Container doomsday-notifications  Starting
 Container doomsday-notifications  Started
 Container doomsday-notifications  Waiting
 Container doomsday-notifications  Healthy
2023/07/31 23:32:09 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 23.0.5
  API Version: 1.42
  Operating System: Docker Desktop
  Total Memory: 7951 MB
panic: test timed out after 30s
running tests:
        TestMain (30s)

Additional information

No response

@n-tucker n-tucker added the bug An issue with the library label Jul 31, 2023
@mdelapenya
Copy link
Member

Hey @n-tucker thanks for reporting this issue. I think this could be related to #1373 too. We added a docker host resolution algorithm and taking a deeper look, it's not taking into account the InAContainer function. Please look at this another issue that was solved for the k3s module: #1289

I'll be working on this next week.

@mdelapenya mdelapenya added the compose Docker Compose. label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library compose Docker Compose.
Projects
None yet
Development

No branches or pull requests

2 participants