GitLab CI: cannot connect to embedded tomcat on localhost

I am trying to connect to a local web service running on a docker VM, the docker VM is spun up by GitLab.com CI. Whenever trying to curl localhost:<port name> I always get connection refused.

Whenever I try ss -lt after starting the web service with the embedded tomcat it returns no open ports. So I do not understand why tomcat (I assume) is not getting picked up when the application is clearly running.

Below are the steps I have used to reproduce the issue:

Firstly the web service is the basic project provided by [spring][1], I have copied the GitHub repository into my own GitLab repo. This web service runs on ports 9000 and 9001, and running locally curl returns data from the web service

To trigger automatic builds in GitLab CI a .yml file is used.
The first run I just executed the web service (knowing it would continuously run) to check that it executed correctly.

.gitlab-ci.yml

image: maven:3.3.9-jdk-8

test:
    script:
    - mvn -f complete/pom.xml clean compile
    - mvn -f complete/pom.xml package
    - java -jar complete/target/gs-actuator-service-0.1.0.jar

1st Run Output:

...
$ java -jar complete/target/gs-actuator-service-0.1.0.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.5.RELEASE)

2016-05-30 11:57:29.030  INFO 144 --- [           main] hello.HelloWorldConfiguration            : Starting HelloWorldConfiguration v0.1.0 on runner-8a2f473d-project-1243034-concurrent-0 with PID 144 (/builds/Steven/testProject/complete/target/gs-actuator-service-0.1.0.jar started by root in /builds/Steven/testProject)
2016-05-30 11:57:29.035  INFO 144 --- [           main] hello.HelloWorldConfiguration            : No active profile set, falling back to default profiles: default
2016-05-30 11:57:29.214  INFO 144 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7a50143b: startup date [Mon May 30 11:57:29 UTC 2016]; root of context hierarchy
2016-05-30 11:57:32.634  INFO 144 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9000 (http)
2016-05-30 11:57:32.653  INFO 144 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-05-30 11:57:32.655  INFO 144 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.33
2016-05-30 11:57:32.878  INFO 144 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-05-30 11:57:32.878  INFO 144 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3671 ms
2016-05-30 11:57:33.536  INFO 144 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-05-30 11:57:33.544  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'metricFilter' to: [/*]
2016-05-30 11:57:33.545  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-05-30 11:57:33.545  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-05-30 11:57:33.545  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-05-30 11:57:33.545  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-05-30 11:57:33.546  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2016-05-30 11:57:33.546  INFO 144 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'applicationContextIdFilter' to: [/*]

The output shows tomcat running on port 9000

Running another build to run the web service in the background an trying to connect to it demonstrates the issue with connecting to localhost

.gitlab-ci.yml

image: maven:3.3.9-jdk-8

test:
  script:
    - mvn -f complete/pom.xml clean compile
    - mvn -f complete/pom.xml package
    - java -jar complete/target/gs-actuator-service-0.1.0.jar &
    - ps -ef
    - ss -lt
    - curl localhost:9000

2nd Run Output

...

$ java -jar complete/target/gs-actuator-service-0.1.0.jar &
$ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 12:03 ?        00:00:00 /bin/bash
root         8     1  0 12:03 ?        00:00:00 /bin/bash
root       143     8  0 12:04 ?        00:00:00 java -jar complete/target/gs-actuator-service-0.1.0.jar
root       144     8  0 12:04 ?        00:00:00 ps -ef
$ ss -lt
State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port   
$ curl localhost:9000
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to localhost port 9000: Connection refused

The 1st run output clearly shows the application running on port 9000, and the 2nd run shows the process of the application is running. So why does ss -lt return nothing and not connect to localhost:9000?

Please note I have also tried:

Does anyone know why I cannot connect to my running web service?
[1]: https://spring.io/guides/gs/actuator-service/#use-maven

Same issue here. Did you ever get it working?

I have a similar issue… Did you manage to get it working?