Hi,
I'm connecting to a remote DB with a port forward (with AWS ssm, AWS-StartPortForwardingSessionToRemoteHost): aws ssm start-session --target i-XXXXX --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"portNumber":["5432"],"localPortNumber":["5432"], "host":["XXXXX.rds.amazonaws.com"]}'
The connection locally works fine:
$ telnet localhost 5432
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
But if I try to reach it within docker, it doesn't work:
$ docker run --add-host host.docker.internal:host-gateway mikesplain/telnet host.docker.internal 5432
telnet: can't connect to remote host (172.17.0.1): Connection refused
I'm in a situation where I can't use --network=host.
Am I missing something here ?
Seems strongly related to https://stackoverflow.com/questions/69222946/access-aws-ssm-port-inside-docker-container
Thanks,
Hi, I'm sorry I don't get it. Do you suggest running the port-forward within the container ? That's not a solution neither, it's a container I can't modify, so I can't install the aws cli/ssm plugin in it.
No, it is your local PC that executes this command.
But what's the difference with the command I'm already running on the host machine ? I'm already running in from my local PC where I run the docker container. It just that the PC can connect to the DB but when in the container, it doesn't work.
To begin with, the IP address of the host is "172.17.0.1", is this correct?
Yes, if I test the connection with a local nginx for example, it works. It only doesn't work with the SSM port-forward. I've asked a friend of mine to test on MacOS, it seems to work. Looks like the issue is only with Linux.