Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

huangapple go评论60阅读模式
英文:

Gitlab Job failed keeps failing during "prepare environment" since it cannot link container

问题

以下是要翻译的内容:

Docker构建作业一直失败,并显示以下错误:

“错误:作业失败(系统故障):准备环境:守护程序的错误响应:无法链接到非运行容器:/runner-3fjcetbw-project-36861-concurrent-0-8c1f412098c40e0b-docker-0 作为/runner-3fjcetbw-project-36861-concurrent-0-8c1f412098c40e0b-predefined-0/docker(exec.go:73:0s)。请查看https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading 获取更多信息”

对此有什么想法吗?

编辑 2: 我已经在特定的runner中使其工作,现在的问题是为什么它在共享runner中不起作用。

这是我遵循的指南:https://about.gitlab.com/handbook/customer-success/professional-services-engineering/education-services/gitlabcicdhandsonlab8.html

以下是.gitlab-ci.yml文件

stages:
    - test
    - build

variables: 
    INLINE_GLOBAL_VARIABLE: "我是在CI/CD配置文件的全局级别设置的内联变量"

test job:
    stage: test
    script:
        - echo "我是一个单元测试!"

build job:
    stage: build
    script:
        - echo "我是一个构建镜像!"

environment echoes:
  stage: build
  script:
    - echo "我是谁..."
    - whoami
    - echo "我在哪里..."
    - pwd
    - ls -al
    - echo "这是我们环境中的可用内容..."
    - env

environment variables:
  stage: build
  variables:   
   INLINE_LOCAL_VARIABLE: "我是在CI/CD配置文件的作业级别设置的内联变量"
  script:
    - echo "在这里做一个测试"
    - echo "这些是一些默认的、全局的和本地的变量..."
    - echo $CI_COMMIT_SHORT_SHA
    - echo $group_level_variable
    - echo $project_level_variable
    - echo $INLINE_GLOBAL_VARIABLE
    - echo $INLINE_LOCAL_VARIABLE

build image:
  stage: build
  image: docker:18
  services:
    - docker:18-dind
  variables:
    IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
  script:
    - echo $IMAGE
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $IMAGE .
    - docker push $IMAGE

Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

编辑 1: 该作业使用由GitLab提供的共享runner
Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

编辑 2: 一个特定的runner似乎正在工作。

runner的config.toml文件

concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "AMD-PC"
  url = "https://spt.gitlabtraining.cloud/"
  id = 4316
  token = "xxxxxxxxxxxxxxxxx"
  token_obtained_at = 2023-03-04T04:09:18Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "docker"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache", "/certs/client"]
    shm_size = 0

之前的值

privileged = false
volumes = ["/cache"]

Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

英文:

Docker build job keeps failing with below error:

"ERROR: Job failed (system failure): prepare environment: Error response from daemon: Cannot link to a non running container: /runner-3fjcetbw-project-36861-concurrent-0-8c1f412098c40e0b-docker-0 AS /runner-3fjcetbw-project-36861-concurrent-0-8c1f412098c40e0b-predefined-0/docker (exec.go:73:0s). Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information"

any idea on this?

Edit 2: I got it working in specific runner, now the question is why is it not working in a shared runner

This is the guide I followed: https://about.gitlab.com/handbook/customer-success/professional-services-engineering/education-services/gitlabcicdhandsonlab8.html

Here's the .gitlab-ci.yml file

stages:
    - test
    - build

variables: 
    INLINE_GLOBAL_VARIABLE: "I'm an inline variable set at the global level of the CI/CD configuration file"

test job:
    stage: test
    script:
        - echo "I am a unit test!"

build job:
    stage: build
    script:
        - echo "I am a build image!"

environment echoes:
  stage: build
  script:
    - echo "Who am I running as..."
    - whoami
    - echo "Where am I..."
    - pwd
    - ls -al
    - echo "Here's what is available in our environment..."
    - env

environment variables:
  stage: build
  variables:   
   INLINE_LOCAL_VARIABLE: "I'm an inline variable set at the job level of the CI/CD configuration file"
  script:
    - echo "Do a test here"
    - echo "Here are some default, global, & local variables..."
    - echo $CI_COMMIT_SHORT_SHA
    - echo $group_level_variable
    - echo $project_level_variable
    - echo $INLINE_GLOBAL_VARIABLE
    - echo $INLINE_LOCAL_VARIABLE

build image:
  stage: build
  image: docker:18
  services:
    - docker:18-dind
  variables:
    IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
  script:
    - echo $IMAGE
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $IMAGE .
    - docker push $IMAGE

Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

Edit 1: The job is using a shared runner provided by gitlab
Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

Edit 2: A specific runner seems to be working.

config.toml of the runner

concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "AMD-PC"
  url = "https://spt.gitlabtraining.cloud/"
  id = 4316
  token = "xxxxxxxxxxxxxxxxx"
  token_obtained_at = 2023-03-04T04:09:18Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "docker"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache", "/certs/client"]
    shm_size = 0

prior values

privileged = false
volumes = ["/cache"]

Gitlab Job failed keeps failing during “prepare environment” since it cannot link container.

答案1

得分: 1

以下是翻译好的部分:

"Replace build image job with below fixes this" 可以翻译为 "使用下面的内容替换构建镜像任务可以修复此问题:"

"For some reason version 18, is throwing an error" 可以翻译为 "由于某种原因,版本 18 报错了。"

英文:

Replace build image job with below fixes this

build image:
  stage: build
  image: docker:20.10.17
  services:
    - docker:20.10.17-dind
  variables:
    IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
    DOCKER_TLS_CERTDIR: ""
  script:
    - docker --version
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $IMAGE .
    - docker push $IMAGE

For some reason version 18, is throwing an error

https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/121189#note_1308494287

huangapple
  • 本文由 发表于 2023年3月4日 01:03:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定