I am trying to use Gitlab CI to build a docker Nginx image then run & test a container by calling cURL on that container's Domain:PORT like this:
.gitlab-ci.yml:
variables:
IMAGE_NAME: docker_curl_sandbox_img
CONTAINER_NAME: docker_curl_sandbox_cont
image: docker:latest
services:
- docker:dind
stages:
- build
- test
build_docker_img:
stage: build
only:
- master
script:
- docker build -t $IMAGE_NAME .
test_run_docker:
stage: test
only:
- master
before_script:
- apk add --update curl && rm -rf /var/cache/apk/*
script:
- docker kill $CONTAINER_NAME || true
- docker rm $CONTAINER_NAME || true
- docker run -p 8087:80 --name $CONTAINER_NAME -d $IMAGE_NAME
- sleep 25
- docker ps
- cat /etc/hosts
- curl http://docker:8087
Dockerfile:
FROM nginx
COPY ./src /usr/share/nginx/html
I have tried:
curl http://docker:8087
,
curl http://0.0.0.0:8087
,
curl http://localhost:8087
,
... I have tried the domains from /etc/hosts
with no luck:
but I am keep getting: curl: (7) Failed to connect to 0.0.0.0 port 8087: Connection refused
any idea? thanks
Update: adding results of docker ps
and netstat -na
: