SSH proxy on containers


I need my containers to access the internet through an ssh proxy. (Socks5 dynamic port forwarding).
I am currently testing with a first container (jdownloader2) where I have the possibility to configure a socks proxy.
Currently I have a second container (ssh-client) and I to specify the ip of the container2 (docker inspect), so that the container1 connects to it.

I do not think it’s the best solution or the most secure.
Do I have to make a link between the two containers? Or use the ssh client from the host? Or insert ssh into container 1?

Thanks for your help