gpt4 book ai didi

docker - 如何查找在gitlab中运行的docker-in-docker的URL

转载 作者:行者123 更新时间:2023-12-02 19:15:30 25 4
gpt4 key购买 nike

我有一个在docker中运行的新应用程序(https://gitlab.com/connorbutch/reading-comprehension/-/tree/5-implement-glue-code,目前正在使用 5-implement-glue-code 分支)运行(目前,它最终将在knative中运行)。该应用程序将构建(在本地和gitlab ci / cd服务器上),并部署一个docker镜像(在本地和gitlab ci / cd服务器上)。它还在本地通过了验收测试。但是,当它在gitlab ci / cd服务器上运行验收测试时,似乎docker部署未在其他主机/ URL上公开/发生。
如果您希望在本地运行此命令,则可以使用一个命令轻松地完成此操作(克隆/ cd到仓库后):docker run -i --rm -p 8080:8080 registry.gitlab.com/connorbutch/reading-comprehension & ./wait-for-it-2.sh。如果没有,您可以通过cd重新创建到仓库并运行./build-it.sh这是gitlab服务器上失败构建的输出(运行上面提到的命令docker run -i --rm -p 8080:8080 registry.gitlab.com/connorbutch/reading-comprehension & ./wait-for-it-2.sh时)。您可以在这里找到此输出: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
如上所述,它在本地工作。这是本地运行时的输出(使用同一命令)
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
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: */*
这是我的.gitlab-ci.yml(位于: 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
gitlab服务器中的docker ps的输出似乎显示了我的期望(如下所示):
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
以下是来自docker inspect的相关摘录(在gitlab ci服务器上运行的容器上):
 "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
}
}
}
我怀疑是gitlab ci服务器中运行的docker service中的docker正在另一台主机上运行,​​或者未设置为处理流量。有人对造成这种情况有任何想法吗?
谢谢,
康纳

最佳答案

尝试使用docker:8080代替localhost进行连接。我不太确定,但我认为我遇到了这个问题。在这种情况下,您的服务不会暴露给主机,而是会暴露给服务。希望这能解决您的问题。

关于docker - 如何查找在gitlab中运行的docker-in-docker的URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63696871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com