GitLab CI执行docker命令报错:lookup docker on 127.0.0.11:53: no such host
问题:GitLab CI中执行Docker命令时出现主机查找失败错误
我在GitLab CI中运行自动化测试,测试过程需要执行多个docker exec命令,但遇到了如下错误:
error during connect: Get "http://docker:2375/v1.24/containers/json": dial tcp: lookup docker on 127.0.0.11:53: no such host
我找到过一个解决方案,但它仅适用于自行托管GitLab Runner的场景,而我们并未自行托管,无法使用该方案。
以下是我简化后的.gitlab-ci.yml配置:
image: docker:23.0.3 variables: GIT_SUBMODULE_STRATEGY: recursive DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: '' FF_NETWORK_PER_BUILD: 1 CI_DEBUG_SERVICES: "true" services: - name: registry.gitlab.com/path/to/image:tag alias: 'testserver' stages: - test - deploy cache: paths: - node_modules/ test: stage: test before_script: - echo '>>>>> DEBUG - install all required packages and project dependencies' - apk update && apk add nodejs npm git - npm install --global yarn - yarn install script: - echo '>>>>> DEBUG - list docker containers' - docker ps - echo '>>>>> DEBUG - run tests' - yarn test:ci artifacts: reports: coverage_report: coverage_format: cobertura path: coverage/cobertura-coverage.xml coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
我添加了docker ps命令查看运行中的容器,但依旧出现相同错误:
error during connect: Get "http://docker:2375/v1.24/containers/json": dial tcp: lookup docker on 127.0.0.11:53: no such host
内容的提问来源于stack exchange,提问作者dokgu
相关产品推荐
相关产品推荐

