Connecting Jenkins to Docker on Windows 10 - connection refused - docker

Running jenkins on latest image in container in windows 10. Also have docker for desktop. In docker GUi, i checked the open port 2375 for tcp connections checkbox.
Still, when trying to add docker as cloud in jenkins at tcp://localhost:2375 i get connection refused.
What is wrong ?

Related

VSCode remote can't open a remote container with ssh access>

I have a remote container with ssh access. I tried to use vscode remote to connect to that container but it shows "The VS Code Server failed to start."
The container only has ssh port mapped on the host(mac). Does the vscode need other ports than ssh port to establish a connection?
Thanks.

Docker Windows dial tcp 127.0.0.1:2376: connectex: No connection could be made because the target machine actively refused it

I just installed Docker Desktop on Windows 10 and while running the command docker run hello-world, I keep getting the error "dial tcp 127.0.0.1:2376: connectex: No connection could be made because the target machine actively refused it"
Any solution to this problem, From other stackoverflow answers, I deleted the DOCKER_* env variables, but it did not solve the problem.
I even selected "Expose daemon on tcp://localhost:2375 without TLS" option as told by the answer in this link: Docker: No connection could be made because the target machine actively refused it
There were some solutions involving docker-machine command (see the link), but the windows powershell cannot find the command.
Any help is appreciated.
Remove DOCKER_TLS as well as DOCKER_HOST environment variables. Have your docker desktop running.
Then try executing:
docker run -d -p 80:80 docker/getting-started
It should work.

jenkins as docker container refused to connect to docker daemon in ubuntu

I'm running jenkins in docker container and docker daemon on same ubuntu machine, had a issue to connect to docker daemon.
check with netstat and telnet the connection is already running and connected.
i did refer to this and few more but still no luck, really need an advise on this.
https://www.jenkins.io/doc/book/installing/docker/
Jenkins: Can't connect to Docker daemon

Unable to access Docker container running in WSL2

I am new to containers and Docker. On my Windows 10 laptop (Version 20H2 Build 19042.630) I have WSL2 installed as well as Docker Desktop (Docker Engine v19.03.13). When I run the command below (from the docker documentation):
docker run -d -p 80:80 docker/getting-started
The container starts fine but I am unable to access the container from either within WSL or from the Windows 10 host.
Inside WSL, if I enter curl http://127.0.0.1 it returns the error curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
From the Windows 10 host, if I open a browser and attempt to go to http://127.0.0.1 it just throws a 404 error.
From the Windows 10 host, when I open the Docker Desktop app, it shows the container running and listening on port 80 but if I then stop the container...and then attempt to restart it, it throws an error that says:
(HTTP code 500) server error - Ports are not available: listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions
I have tried completely uninstalling WSL and Docker Desktop and resetting the TCP/IP stack but the end result is the same. I performed the exact same install steps on my desktop PC and everything works fine with no issues. I did notice on the desktop PC that the first time I tried accessing the "getting-started" container that it produced a pop-up to allow the traffic through my firewall. I never got this on the laptop. I compared the firewall rules on the PC to the Laptop and the PC had 4 rules for the com.docker.backed application that the Laptop did not have. I manually duplicated those rules on the laptop but it did not change the behavior any.
EDIT:
After doing more research on this issue...discovered why this is happening. The ports the container is attempting to listen on are excluded for my Laptop. Found the Github issue linked below that had the command netsh interface ipv4 show excludedportrange protocol=tcp that showed the list of excluded ports on my laptop. Seems Hyper-V is what is excluding the ports but the only reason Hyper-V is on the system is for WSL. The Github issue is still open as of today.
Unable to bind ports: Docker-for-Windows & Hyper-V excluding but not using important port ranges #3171
If your docker container uses localhost inside it won't work. I had the same issue with docker inside wsl and the solution was to change IP of underlying service (the one that is run inside docker) to 0.0.0.0.
You can check this by doing docker ps. In my case I ran the docker like this:
docker run --rm -p 8080:8080 hello-python
which was then bind to (part of docker ps output):
0.0.0.0:8080->8080/tcp
So basically the python code had to use 0.0.0.0:8080 instead of localhost:8080

Is there a way to make a JMX connection, over SSH, to a remote process running inside a docker container?

I'm trying to establish a JMX connection, over SSH tunnel, to a process running inside a remote docker container. From Java Mission Control, VisualVM or JConsole the connection times out and I'm unable to connect.
The JMX connection is established if I connect, in JConsole (or any of the others), directly to the remote machine ip. The problem arises when I use a SSH tunnel.
I'm establishing an SSH tunnel from my local machine to the remote machine with
ssh username#remote-machine-ip -L 9090:127.0.0.1:9090
In the docker container I'm exposing the port 9090 and I'm using the following arguments for the JVM:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.port=9090
-Dcom.sun.management.jmxremote.rmi.port=9090
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=127.0.0.1
-Djava.rmi.server.useLocalHostname=true
In -Djava.rmi.server.hostname I tried already using 127.0.0.1, localhost, the docker containers host machine ip...
In JConsole I'm using 127.0.0.1:9090 to connect.
Running tcpdump on the remote machine I'm able to capture some packets arriving at port 9090 but in JConsole it fails with "Connection failed".
Any idea of what I'm doing wrong?
Everything was correct... more or less.
My local machine runs Windows and I was creating the SSH tunnel on Git Bash!
If I create the SSH tunnel with the Windows command line or with Putty it works just fine...

Resources