Remote port forwarding inside Docker containers

Aha! I figured it out. This was because docker was creating an ipv6 internal network for my containers, and my kernel did not have ipv6 forwarding enabled. So when running sshd outside of the container, it would work over ipv4, but when running sshd inside of the container on the docker bridge network, it would listen on ipv6 and be unable to open port forwards.

Once I enabled ipv6 forwarding, (adding net.ipv6.conf.all.forwarding = 1 in /etc/sysctl.conf and rebooting) everything starting working just fine.


You could also try forcing sshd to use ipv4. In your example, adding switch "-4" as follows:

ssh -4 -R 2024:localhost:22 -N remote.server