Search code examples
dockerdocker-composeapache-nifissh-tunnel

ssh tunnel to container inside remote host


I am running Nifi (A GUI based application) inside Docker container. it was deployed using docker compose

compose:

    nifi:
        hostname: DWH_Nifi_prod
        container_name: nifi_container_persistent
        image: 'apache/nifi:1.19.0'  # latest image as of 2023-June.
        restart: on-failure
        user: root
        ports:
            - '8091:8080'

It is up and running.

Now as i want to open the UI, i need to open a ssh tunnel to it.

Earlier when i ran the application on the remote host (not on docker) I could easily establish the Tunnel using

ssh -L 8091:127.0.0.1:8091 root@remote_host.prod

Now i tried something similar

ssh -L 8080:127.0.0.1:8080 root@remote_host.prod

but could not succeed (error when opening UI : localhost sent an invalid response.)

Can someone please help me if there is anything extra to be taken care to establish a ssh tunnel for Remote hosts docker container ?


Solution

  • As I observed there is no difference in establishing ssh tunnel to container. its same as establishing to host machine.

    ssh -L 8091:127.0.0.1:8091 root@remote_host.prod worked.

    Earlier I could not access the page as my url is using https://, but i should use http:// only.