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

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.

Related

How to connect to SSH host from Docker container running on SSH remote

I run applications on both SSH host and remote PC. A client application runs in a Docker container on the remote. A server application runs on the host.
I want the client app to connect to the server app.
Host: Windows 10
Remote: Ubuntu 18.04
I connect to SSH remote using remote port forwarding like this.
ssh user#address -i xxx.pem -R 54321:localhost:54321
And run the Docker container on the SSH remote like this.
docker run -it -p 54321:54321 some_container bash
Then, I got this error.
Error starting userland proxy: listen tcp 0.0.0.0:54321: bind: address already in use.
How do I solve this?
I tried to use iptables instead of "docker -p". But I don't know what I describe.

Connecting Jenkins to Docker on Windows 10 - connection refused

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 ?

Connect to remote Docker Daemon

I have a Windows 10 Home machine (local machine) where I have installed Docker Toolbox that runs docker inside a VM. IP (192.168.0.6)
Also, there is another Windows 10 Pro machine (remote machine) that has Docker Desktop installed. IP (192.168.0.13). In the Docker Desktop setting, I have enabled "Expose daemon on tcp://localhost:2375 without TLS". At this point, I do not care about the TLS part since both the machines are on the local network. In the firewall setting, I have accepted inbound connections from port 2375.
Now I would like to run docker-compose from a local machine that connects and runs docker on the remote machine. To test connection, the command used on local machine is
docker -H tcp://192.168.0.13:2375 version
The response is
Cannot connect to the Docker daemon at tcp://192.168.0.13:2375. Is the docker daemon running?
I see that it calls https://192.168.0.13:2375/v1.40/info and not http://192.168.0.13:2375.
And in my remote machine, if I enter http://localhost:2375/v1.40/info I get a response but there is no response when I run by providing IP like http://192.168.0.13:2375/v1.40/info
I assume your docker daemon is only listening on localhost or 127.0.0.1.
You try to connect from another machine which connects to your machine with you internal network ip 192.168.0.13.
This means you need to configure your docker daemon to listen to:
192.168.0.13 = only network internal
tcp://192.168.0.13:2375
0.0.0.0 = all ip addresses
tcp://0.0.0.0:2375
In Windows you need to create a Docker-Daemon config file in:
C:\ProgramData\docker\config\daemon.json
with following content:
{
"hosts": ["tcp://0.0.0.0:2376"] # IP Address for container host
}
You can probably define a Subnet but i am not sure about this.
This is because the VM network interface is only binded to your localhost.
Try forwarding the port. From powershell or command prompt with admin privileges:
netsh interface portproxy add v4tov4 listenport=2375 listenaddress=192.168.0.13 connectaddress=127.0.0.1 connectport=2375

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...

Docker: Use Host SSH Forwards in container

I try to access a MS SQL Server from within a Docker container.
The problem is, it is only reachable via an SSH tunnel that I can establish on my host machine. I use a local forward for port 1433, that will automatically be established once I connect to the server.
Using SquirrelSQL for example, I can access the Server via 127.0.0.1:1433 with no problem.
But from within my docker container I am unable to do so.
I already tried to run the docker container with --expose 1433 -p 127.0.0.1:1433:1433 but that didn't work out.
Host is running Ubuntu 16.04, the Docker Container is running on some sort of Debian.

Resources