I have a local MySQL server, that listens to the port 3306 on 127.0.0.1 (not 0.0.0.0!) and though accessible only from my local machine.
I want to run a docker or podman (rootless) container and allow it to connect to my MySQL server.
What I practically trying to do is to pass SSH-Option -L
/-R
port tunnel option to docker run
or podman run
, like so
$ docker run ... -L 3306:localhost:3306
or
$ docker run ... -R 3306:localhost:3306
(depending from which point of view you see this tunnel being established)
I tried to use --add-host=host.docker.internal:host-gateway
option, but it requires me to make MySQL listen to 0.0.0.0:3306 and I don't want to do it due to security reasons.
- My question: How can I create a tunnel between my 127.0.0.1:3306 and to some port within the container?