-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Module
Core
Testcontainers version
1.19.8
Using the latest Testcontainers version?
No
Host OS
MacOS Sonoma 14.6.1
Host Arch
Tried both x86 and ARM
Docker version
Client:
Cloud integration: v1.0.35+desktop.13
Version: 26.0.0
API version: 1.45
Go version: go1.21.8
Git commit: 2ae903e
Built: Wed Mar 20 15:14:46 2024
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.29.0 (145265)
Engine:
Version: 26.0.0
API version: 1.45 (minimum version 1.24)
Go version: go1.21.8
Git commit: 8b79278
Built: Wed Mar 20 15:18:02 2024
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
I'm building a service with spring boot 3 that talks to k8s API using fabric8 java client. So, I want to run full integration tests without any mocks, including k8s cluster. To start k8s in tests I'm using k3s-testcontainers. It starts fine, but then I need a custom registry for k3s to pull my private images from during tests. So I thought I can start a docker registry in testcontainers for this.
The registry starts fine in testcontainers, but I cannot push anything to it. Neither in the code, nor through docker cli when the test is paused in the debug mode. I prepared a minimal demo to reproduce the issue: https://github.com/pfilaretov42/spring-testcontainers-registry
Here is how to reproduce the issue using my repository above:
- Set breakpoint in
TestcontainersTestclass, on"set breakpoint here"line. - Debug
TestcontainersTest.test()(e.g. in IntelliJ IDEA) - When paused, notice the mapped port for the registry container, e.g.
57025:docker ps | grep registry - Pull, tag, and push image to the registry:
% docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
478afc919002: Pull complete
Digest: sha256:91fb4b041da273d5a3273b6d587d62d518300a6ad268b28628f74997b93171b2
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
What's Next?
1. Sign in to your Docker account → docker login
2. View a summary of image vulnerabilities and recommendations → docker scout quickview hello-world
% docker tag hello-world localhost:57025/hello-world
% docker push localhost:57025/hello-world
Using default tag: latest
The push refers to repository [localhost:57025/hello-world]
Get "http://localhost:57025/v2/": dial tcp [::1]:57025: connect: connection refused
% docker tag hello-world 127.0.0.1:57025/hello-world
% docker push 127.0.0.1:57025/hello-world
Using default tag: latest
The push refers to repository [127.0.0.1:57025/hello-world]
Get "http://127.0.0.1:57025/v2/": dial tcp 127.0.0.1:57025: connect: connection refused
% docker tag hello-world 0.0.0.0:57025/hello-world
% docker push 0.0.0.0:57025/hello-world
Using default tag: latest
The push refers to repository [0.0.0.0:57025/hello-world]
Get "https://0.0.0.0:57025/v2/": http: server gave HTTP response to HTTPS client
As you can see I tried different host names (localhost, 127.0.0.1, 0.0.0.0) but nothing works.
And here is how it works with plain docker cli, i.e. no testcontainers:
% docker run -d --rm -p 5000:5000 --name registry registry:2
443f9ea881257529793b059442a24be96e992123a484b756b8d1ae41eec4a332
% docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
Digest: sha256:91fb4b041da273d5a3273b6d587d62d518300a6ad268b28628f74997b93171b2
Status: Image is up to date for hello-world:latest
docker.io/library/hello-world:latest
What's Next?
1. Sign in to your Docker account → docker login
2. View a summary of image vulnerabilities and recommendations → docker scout quickview hello-world
% docker tag hello-world localhost:5000/hello-world
% docker push localhost:5000/hello-world
Using default tag: latest
The push refers to repository [localhost:5000/hello-world]
12660636fe55: Pushed
latest: digest: sha256:a8ea96bb64d60208d6a56712042d1cf58aa4a7d3751b897b9320b0813c81cbb4 size: 524Relevant log output
No response
Additional Information
I cannot use the latest version of testcontainers since the version is defined by the spring boot starter org.springframework.boot:spring-boot-testcontainers.