Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Gitlab-CI: Access nginx service in script section

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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).
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading