I just installed redash using the provided docker-compose.yml file. I need to connect to MySQL using a SSH tunnel.

As I understand it, I need to do so manually, but I’m not sure from what container should I do it. I tried it from server and scheduler, but none worked.

Any pointer?

My suggestion is to run another Docker Compose service that setups the tunnel and make it available to the other ones. You can use autossh for this. I never tried using it in a Docker Compose environment, but this seems like a possible approach.

The server container needs access to the tunnel (as it runs a connection test) and then to the adhoc/scheduled workers as they run the queries.

Btw, which docker-compose.yml did you use?

Hello @arikfr thanks for your input. I was trying to use the autossh docker container and did setup everything as described. I still gett error messages when trying to connect to the database in redash. I’m not a docker expert, but this is what I tried:

  • define fixed ip address to the containers, to use this ip address in the redash data source (did not work)
  • use default network and get ip address (did not work)
  • use 127.0.0.1 or localhost (did not work)

Logs of the autssh container are looking fine, no errors so I would say the connection is up and running.
Would love to get your thoughts on that.
Thanks.

1 Like

Found a solution after reading some documentations about docker network.

Solution for me:

  • autossh on the host
  • figure out your host ip (should be 172.17.0.1, get it by running ip addr show docker0 on your host)
  • create autossh command and add this as your “Listening ip”

The command is looking like this with the following assumptions:

  • host IP: 172.17.0.1
  • local port: 33061
  • remote ip: 3306
  • ip of your mysql db: 10.10.10.1
  • user of the server you are tunneling through: user
  • ip of the server your are tunneling through: 10.10.10.99

sudo autossh -f -N -i /path/to/key -L172.17.0.1:33061:10.10.10.1:3306 user@10.10.10.99 -C -4

hopefully this is helping somebody :slight_smile:

1 Like