I'm trying to establish an SSH tunnel connection from inside a Docker container.
I created a brief shh-tunnel.sh script that allows the connection:
ssh-tunnel.sh
ssh -4 -q -f -T -M -N -L 127.0.0.1:5433:credentials:more_credentials USER@HOST
Then I run it from inside the .Dockerfile, like this:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y -qq python3 python3-pip openssh-client
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y postgresql postgresql-contrib
COPY ssh-tunnel.sh .
(other things ...)
RUN chmod u+x ./ssh-tunnel.sh
CMD ./ssh-tunnel.sh
All looks fine when I run docker build. My question is... how can I keep the connection established when I run docker run?