I want to connect to the Apache created in my gitlab-ci.yml
(in order to run acceptance tests), but I don't understand how to do it.
Trying to curl -i http://localhost/
gives:
curl: (7) Failed to connect to localhost port 80: Connection refused
Content of gitlab-ci.yml
image: php:7.0-apache
variables:
DEBIAN_FRONTEND: noninteractive
before_script:
- apt-get update -yqq
- apt-get install -yqq curl net-tools
hello-world:
stage: test
script:
- ./script.sh
Content of script.sh
#!/usr/bin/env bash
set -e
echo-run() {
echo "===== ===== $1"
echo "$($1)"
echo
}
declare MYHOSTNAME="$(hostname)"
echo-run "hostname"
echo-run "netstat -antup"
echo-run "pwd"
echo-run "ls -al --color=auto ."
echo "curl -i http://${MYHOSTNAME}/"
# This does not work: "failed to connect to <hostname> port 80: Connection refused"
curl -i http://${MYHOSTNAME}/
The project is hosted at gitlab.com/matt.faure/debug-ci/ and here is the ouput of a failed job
As far as I understand this an "inception" problem: in which world am I ?
MYHOSTNAME
is the hostname of the Docker container, obviously this won't work as is it the name seen from inside the container, and IP/ports are mapped by the Runner (or maybe not). So what is the default mapping ? How to configure it ?
(This works in a regular Docker environment)
I harvested the Gitlab Runner doc without success. I also did extensive searches on Gitlab Forum and StackOverflow. I found these similar questions but none of them led me to a solution:
- How are Gitlab CI service ports exposed?
- Accepted answer to GitLab runner unable to clone repository via http
- Gitlab runner: Not able to contact running webserver
Summed up, what am I missing or misunderstanding ?