I have got a container with Jenkins. I am trying to run tests pipeline inside this container. Tests uses Testcontainers. I am struggling with error:
18:36:15.560 [testcontainers-ryuk] WARN org.testcontainers.utility.RyukResourceReaper - Cannot connect to Ryuk at 172.17.0.1:55592
java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at org.testcontainers.utility.RyukResourceReaper.lambda$null$0(RyukResourceReaper.java:92)
at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27)
at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$1(RyukResourceReaper.java:88)
at java.base/java.lang.Thread.run(Thread.java:829)
Jenkins container was run by command
docker run -v /var/run/docker.sock:/var/run/docker.sock -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 5000:5000 -d --restart always <img>
I've tried to run Jenkins container with --network="host" but same effect.
When I am running those tests directly on my local machine by mvn clean verify, tests passed and this error didn't occur.
EDIT:
I've changed network to bridge (--network="bridge") for Jenkins container. In test I used explicite network bridge:
new GenericContainer("mongodb:1..").withNetworkMode("bridge")...
Ryuk container is created (I can see three containers on my host docker - jenkins, mongo, ryuk) and when I run docker network inspect bridge I can see three containerers are attatched to it. But when I am trying connect to Ryuk container using gateway (172.17.0.1) from Jenkins container using telenet it is NOT possible. But when I am using Ryuk IP (172.17.0.2) instead of gateway's IP I can connect. Then I've create other container on my host and tryied to connect to it form Jenkins container via gateway's IP - could do it.
SOLUTION
Just run Jenkins container with -v /var/run/docker.sock.raw:/var/run/docker.sock instead of -v /var/run/docker.sock:/var/run/docker.sock.
Thanks #Kevin Wittek!
As mentioned in one of the comments, this originates from an issue in Testcontainers for Java regarding an upstream change in Docker Desktop (see this issue).
The current workaround for Mac is to mount the raw socket when creating the container:
-v /var/run/docker.sock.raw:/var/run/docker.sock
Related
My GCP ES service is port forwarded to localhost:9200 of my machine. I am able to log ingest from the local machine.
I have created JAVA script to do the same task and It is also running fine when I am running local
Now, I have created docker Image of that Java project using dockerFile and when I am creating a container, then I am getting the following error
Connect to localhost:9200 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Docker command :
docker run -it --net="host" gcplogingest:latest mvn -f BEATLe/pom.xml test -Dcomponent=detect -DtestSuite=CommonXML/Detect_loginjectionGCP
Note :
I have tried using --network="host" but I am still getting the same error.
Please suggest.
Have you tried removing --net=host and then use in your docker host.docker.internal instead 127.0.0.1?
Consider that your host localhost should be different than your docker localhost, and once you get that removing network=host, you need to access from docker to
host.docker.internal:9200
I have a java application and it can successfully connect to api.meraki.com in my local machine but when I deploy my java application to the test server,
the application which lives in a docker container can not connect to api.meraki.com.
In the host machine, I can also curl the api.meraki.com but inside my docker container (docker exec -it xxx /bin/bash), I can't curl as it gives a connection refused error.
I tried to use a new API key to test server but it is still giving connection refused error. I also tried to allow my test server from Meraki dashboard but no success.
Any ideas that what is the problem and the solution?
edit: i run container with
docker run -dit -p 9078:8080 -e "SPRING_PROFILES_ACTIVE=prod,swagger,preprod" --name abc -v /etc/localtime:/etc/localtime:ro -v /etc/hosts:/tmp/hosts example.com.com:5000/abc:v1.12.5
and in my container when i run getent hosts api.meraki.com resolves dns as:
209.206.57.71 mun211.meraki.com api.meraki.com emea.api.meraki.com n23.meraki.com
test server was behind proxy and it was not configured, configuring both container and the application resolved the problem. (i think the application is connecting other service by bypassing the proxy.
I am trying to connect a mac to a raspberry running Jenkins, to start docker build slaves on the mac on demand. But I can't establish the connection in Jenkins' docker cloud configuration.
My setup is as follows:
raspberry pi at 192.168.2.111: Jenkins running in docker
mac mini at 192.168.2.220 using docker for mac: this should run docker containers as build slaves on demand via Jenkins docker plugin
The SSH connection from Jenkins to mac works. The mac agent is up and running.
Now I want to use the docker plugin for Jenkins and trying to configure the docker cloud.
As docker for mac does not run directly on the host machine (but on hyperkit), they say I should run socat to expose the Unix socket like this:
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2376:2375 alpine/socat TCP-LISTEN:2375,fork unix-connect:/var/run/docker.sock
The container is running:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
76a75c5249d7 alpine/socat "socat tcp-listen:23…" 19 seconds ago Up 17 seconds 127.0.0.1:2376->2375/tcp compassionate_feynman
Then on the Raspberry pi where the Jenkins container is running, I have also added
DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"
at the end of the file /etc/default/docker as described here.
Then in Jenkins cloud config "docker", I set "Docker Host URI" to tcp://127.0.0.1:2376, and the Docker Hostname (The mac mini) to 192.168.2.220. Testing this setting failed.
All the tutorials I find seem to have Jenkins on the same host where the docker slaves will be run. I assume this is why the socat container is not enough in my case?
What is also interesting:
Running curl 127.0.0.1:2376/versionon the mac works (shows expected information), but running curl 192.168.2.220:2376/version from the raspberry does not work (Connection refused). Maybe this can help someone who knows more about networks...
Captain Obvious strikes back.
Just use the network IP instead of localhost when starting socat on the mac.
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 192.168.2.220:2376:2375 alpine/socat TCP-LISTEN:2375,fork unix-connect:/var/run/docker.sock
I currently have a Docker container with Cassandra running within. I am trying to get a visual view using DBVisualizer of said Cassandra. I am using DataStax's Cassandra JDBC driver.
I run my container like so:
docker run --rm -it --net=host -p 9042:9042 [docker image from repo]
The container has an ip of 10.0.72.3
Outside of this container, I am trying to access this cassandra by connecting to:
jdbc:cassandra:Database=Test Cluster;Port=9042;Server=10.0.72.3;
However, I keep getting:
The connection failed: No Cluster node is available..
I have attempted to change cassandra.yaml and change ports, but I am still stuck. Any assistance is appreciated. Thank you
I'm trying to connect the docker selenium remote node to remote docker hub, But it's not connecting, it shows the connection refused exception in Grid console(http://localhost:4444/grid/console) as in below screeshot.
Grid Screenshot:
The command I used to run the Hub on Machine A:
Hub:
docker run -d -p 4446:4444 --name selenium-hub -P selenium/hub
and command I used to register Node in Machine B on same network is:
docker run -d -e HUB_PORT_4444_TCP_ADDR=10.7.30.9 -e HUB_PORT_4444_TCP_PORT=4444 selenium/node-firefox-debug:latest
But getting an error like this:
DefaultRemoteProxy unknown version,Connect to 172.17.0.2:5555 [/172.17.0.2] failed: Connection refused (Connection refused)
I am not an expert on docker, but it looks like you haven't linked both the hub and the node using the --link option. Without that linking the containers I don't think will talk to each other which explains why your registration itself is failing.
Can you please use the --link option and try again as detailed here.
All said and done, it looks like the option --link is getting deprecated in docker and there are alternatives for that. Please refer to this StackOverFlow post for understanding the alternatives.