Reputation: 688
I have a new application (https://gitlab.com/connorbutch/reading-comprehension/-/tree/5-implement-glue-code where I am currently working off of branch 5-implement-glue-code ) that is running in docker (for now, it will eventually run in knative). The application builds (both locally and on the gitlab ci/cd server), and deploys a docker image (both locally and on gitlab ci/cd server). It also passes acceptance tests locally. However, when it runs the acceptance tests on the gitlab ci/cd server, it appears the docker deployment is not exposed/taking place on another host/url.....?
If you wish to run this locally, you can easily do this with a single command (after cloning/cd to the repo): docker run -i --rm -p 8080:8080 registry.gitlab.com/connorbutch/reading-comprehension & ./wait-for-it-2.sh
). If not, you can recreate by cd to the repo and running ./build-it.sh
Here is an output of the failing build on the gitlab server (when running the command mentioned above docker run -i --rm -p 8080:8080 registry.gitlab.com/connorbutch/reading-comprehension & ./wait-for-it-2.sh
). You can find this output here: https://gitlab.com/connorbutch/reading-comprehension/-/jobs/714867229
_ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-09-01 22:25:39,509 INFO [io.quarkus] (main) reading-comprehension-server-quarkus-impl 1.0.0-SNAPSHOT native (powered by Quarkus 1.7.0.Final) started in 0.015s. Listening on: http://0.0.0.0:8080
2020-09-01 22:25:39,509 INFO [io.quarkus] (main) Profile prod activated.
2020-09-01 22:25:39,510 INFO [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jackson, smallrye-context-propagation]
Made request to readiness endpoint (0.0.0.0:8080/health/readiness) and received status code of 000
* Trying 0.0.0.0...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* connect to 0.0.0.0 port 8080 failed: Connection refused
* Failed to connect to 0.0.0.0 port 8080: Connection refused
* Closing connection 0
As mentioned above, it works locally. Here is the output when running locally (using the same command)
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-09-01 23:06:31,525 INFO [io.quarkus] (main) reading-comprehension-server-quarkus-impl 1.0.0-SNAPSHOT native (powered by Quarkus 1.7.0.Final) started in 0.013s. Listening on: http://0.0.0.0:8080
2020-09-01 23:06:31,526 INFO [io.quarkus] (main) Profile prod activated.
2020-09-01 23:06:31,526 INFO [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jackson, smallrye-context-propagation]
//tons of debug logs ommitted for brevity, but you can easily recreate them locally
2020-09-01 23:06:32,112 INFO [com.con.rea.fil.ContainerResponseFilterLoggingImpl] (executor-thread-1) Request received Request method GETRequest headers Accept: */*
Host: 0.0.0.0:8080
User-Agent: curl/7.58.0Request cookies Query parameters Request url http://0.0.0.0:8080//health/readiness with responseResponse body class ReadinessHealthResponse {
isAvailable: true
availableDependencies: [class DownstreamDependency {
name: SystemPropertyChecker
isAvailable: true
}, class DownstreamDependency {
name: MemoryChecker
isAvailable: true
}]
unavailableDependencies: []
}
Response headers Content-Type: application/jsonResponse status code 200
Made request to readiness endpoint (0.0.0.0:8080/health/readiness) and received status code of 200
* Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to 0.0.0.0 (127.0.0.1) port 8080 (#0)
> GET /health/readiness HTTP/1.1
> Host: 0.0.0.0:8080
> User-Agent: curl/7.58.0
> Accept: */*
Here is my .gitlab-ci.yml (found at: https://gitlab.com/connorbutch/reading-comprehension/-/blob/5-implement-glue-code/.gitlab-ci.yml)
image: connorbutch/gradle-and-java-11:latest
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
DOCKER_HOST: "tcp://docker:2375"
DOCKER_DRIVER: "overlay2"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
#By running this as the same service for all build pods, I hope to save an extra docker build
services:
- docker:stable-dind
stages:
- build
- docker_build
- acceptance_test
unit_test:
stage: build
script: ./gradlew check
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
build:
stage: build
script:
- ./gradlew clean quarkusBuild
- ./gradlew clean build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- build
- .gradle
artifacts:
paths:
- reading-comprehension-server-quarkus-impl/build/
docker_build:
stage: docker_build
script:
- cd reading-comprehension-server-quarkus-impl
- docker build -f infrastructure/Dockerfile -t registry.gitlab.com/connorbutch/reading-comprehension .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.gitlab.com/connorbutch/reading-comprehension
acceptance_test:
stage: acceptance_test
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker run -i --rm -p 8080:8080 registry.gitlab.com/connorbutch/reading-comprehension & ./wait-for-it-2.sh
- gradle acceptanceTest
The output of docker ps within the gitlab server seems to show what I expect (given below):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d607ecf87991 registry.gitlab.com/connorbutch/reading-comprehension "./application -Dqua…" 4 seconds ago Up Less than a second 0.0.0.0:8080->8080/tcp reading-comprehension
Relevant excerps from docker inspect (on the container running on the gitlab ci server) are given below:
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 207,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-09-02T00:31:35.621438213Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"NetworkMode": "default",
"PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c18baeec94cb531865994db3184d37949e4c3c34064373ac5d31c49b9eec1d25",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/c18baeec94cb",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "246efed470908aede697bce92f55fb5f58885634eb06ecdbe90686d2beddd41b",
"Gateway": "172.18.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:12:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "d543b622c078986bab878111bb8bbdfe70f4b60fb384c5a7a175295c13ae9d68",
"EndpointID": "246efed470908aede697bce92f55fb5f58885634eb06ecdbe90686d2beddd41b",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
My suspicion is that the docker in docker service running in gitlab ci server is running on another host, or not setup to handle traffic. Does anyone have any ideas on what could be causing this?
Thanks, Connor
Upvotes: 1
Views: 572
Reputation: 2017
Give a try using docker:8080 to connect instead of localhost. I am not totally sure but I think I had this issue with dind. In this situation, your service is not exposed to the host but to dind service. Hope this will solve your issue.
Upvotes: 1