Connecting to local habitat package (jenkins)

I am using a core jenkins plan and have it running in studio, however I am unable to connect to it.

The steps i used to create using core/jenkins

hab studio enter
build
hab svc start /results

Habitat reports jenkins “is fully up and running” but i am unable to connect to port 80 specified in the default.toml or the typical 8080 Jenkins port.

how do i check or configure port forwarding?

Thanks

It’s hard to tell without more information, but assuming you’re on a Mac, the Studio runs in a Docker container, so you’ll need to tell Docker to open the port you want to forward. You can use the HAB_DOCKER_OPTS environment variable for this.

For example, to forward port 80 from the container to your host (allowing you to browse to it at http://localhost):

HAB_DOCKER_OPTS="-p 80:80" hab studio enter

Let me know if that helps!

2 Likes

Thank you for the response. I am working on Windows.

When I input that command, it states it is an unknown command in powershell

For windows, you’ll want to set environment variables this way:

> $ENV:HAB_DOCKER_OPTS="-p 80:80"

Thank you.

It accepts the command but I am still unable to connect.

If I run docker ps, should it show port mappings? Right now it is blank.

A couple things:

  • Make sure you set HAB_DOCKER_OPTS before entering the studio. And to forward 8080 to 80, you would want $ENV:HAB_DOCKER_OPTS="-p 80:8080"
  • Note that Windows containers do not listen on the loopback interface. So you cannot point your browser to localhost. Instead point to the IP address of the container. I use docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <CONTAINER ID> to get the IP
1 Like

Thanks mwrock,

I am now seeing the port forwarding listed under docker ps command. I grabbed the IP for the container and I am not able to ping or connect to it. I am looking into my firewall settings but may have corporate restrictions.

Another thing you can try as long as you have the forwarding working is to browse to the IP address of your local machine. Just don’t use 127.0.0.1. While localhost does not work with windows containers, the LAN IP should work.