Gitlab-CI:docker CURL连接被拒绝

时间:2020-07-22 05:59:37

标签: docker gitlab-ci

我正在尝试在Docker中CURL Web应用程序,但是一直出现连接错误。 curl: (7) Failed to connect to docker port 5001: Connection refused 300. ERROR: Job failed: exit code 7。这是gitlab-ci代码的一部分。

image: docker:19.03.8
services:
  - docker:19.03.8-dind

stages:
  - test

humandetection-test:
  stage: test
  variables:
    port: 5001
    module: humandetection
    image_tag: $CI_REGISTRY_IMAGE/humandetection
  script:
    - docker build -t $image_tag ./$module
    - docker run -d -p $port:$port --name $module $image_tag
    - sleep 15
    - curl http://docker:$port

首先,以上代码可与我在同一存储库中拥有的其他模块配合使用。

第二,当我将构建的映像推送到docker注册表并再次拉回以运行它时,它可以工作。

humandetection-test:
  stage: test
  variables:
    port: 5001
    module: humandetection
    image_tag: $CI_REGISTRY_IMAGE/humandetection
  script:
    - docker build -t $image_tag ./$module
    - docker push $image_tag
    - docker pull $image_tag
    - docker run -d -p $port:$port --name $module $image_tag
    - sleep 15
    - curl http://docker:$port

这对我来说没有意义,并且已经花费了几天的时间进行调试,但没有成功。有人可以帮忙吗?

0 个答案:

没有答案