How to access parent docker from inside a pipe?

Tomer Horowitz October 5, 2023

I have the following step in my pipeline:

 

      - step:
          deployment: Client
          script:
            - apt-get stuff
            - ssh -N -L 4430:some_ip:4430 some_host &
            - sleep 10 # Give SSH tunnel some time to establish
            - curl -k https://localhost:4430 # Works
            - pipe: docker://tomerh2001/gitlab-merge-request-pipe:latest
              variables:
                GITLAB_TOKEN: $GITLAB_TOKEN
                GITLAB_URL: https://host.docker.internal:4430

I am trying to understand which IP/Host I need to specify for the pipe to access the tunnel from the main flow. I tried `host.docker.internal` but that doesn't work.

For context, I have locally replicated the docker run command that bitbucket creates to run the pipe, and it works locally with host.docker.internal when I run the docker image of the custom pipe

I guess that in the pipeline context, the host.docker.internal resolves the host of the docker service itself? And since the SSH tunnel was created inside the pipeline (I.e. a docker container), would I need to somehow find the IP of that container in order to access the tunnel?

My goal is to access the tunnel from within the pipe. Any help will be greatly appreciated!

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 10, 2023

Hi Tomer,

What error do you get when you run the pipe?

Have you tried using http://host.docker.internal:4430 (instead of https)?

I'm not sure about the tunneling, but if I start an HTTP server on the build container on port 8000, the curl command works from within the pipe container if I use curl http://host.docker.internal:8000

I was also curious, why are you using an SSH tunnel instead of the GitLab URL in the GITLAB_URL variable?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events