Cannot connect to localhost, at any listening port, inside gitlab-ci
Summary
A pipeline runner cannot connect to localhost, at any port. Connection gets refused.
Steps to reproduce
- Create an account (if you don't have one already) in gitlab.com
- Create a new repo and put a
.gitlab-ci.ymlinside with:
test_backend_job:
image: debian:latest
script:
- apt-get update && apt-get --assume-yes install netcat
- nohup nc -l localhost 5000 &
- sleep 5
- nc -v localhost 5000
- Commit, Push and let the pipeline run
This script uses netcat to listen to port 5000, and 5 seconds later tries to connect to it.
What is the current bug behavior?
(...)
$ nohup nc -l localhost 5000 &
$ sleep 5
$ nc -v localhost 5000
localhost [127.0.0.1] 5000 (?) : Connection refused
ERROR: Job failed: exit code 1
What is the expected correct behavior?
(...)
$ nohup nc -l localhost 5000 &
$ sleep 5
$ nc -v localhost 5000
Connection to localhost 5000 port [tcp/*] succeeded!
(...)
Edited by Pedro Domingues