How can I access the nginx service in the script section of a Gitlab-CI job?
run_tests:
image: curlimages/curl
stage: test
services:
- name: bitnami/nginx
script:
- curl http://127.0.0.1:8080
At the moment I always get the error:
curl: (7) Failed to connect to 127.0.0.1 port 8080 after 4 ms: Connection refused
According to the bitnami nginx documentation, the container should display the standard page on port 8080.
>Solution :
In your case correct service hostname would be bitnami-nginx and yaml
run_tests:
image: curlimages/curl
stage: test
services:
- name: bitnami/nginx
script:
- curl http://bitnami-nginx:8080
As per https://docs.gitlab.com/ee/ci/services/#accessing-the-services
The default aliases for the service’s hostname are created from its image name following these rules:
- Everything after the colon (:) is stripped.
- Slash (/) is replaced with double underscores (__) and the primary alias is created.
- Slash (/) is replaced with a single dash (-) and the secondary alias is created (requires GitLab Runner v1.1.0 or higher).