gpt4 book ai didi

docker - GitLab CI Runner 无法提取私有(private) Docker 镜像 w。 "no basic auth credentials"但它通过 SSH 工作

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

我已经查看了有关 SO 的相关问题,这似乎不是重复的。

当 GitLab CI Runner 从 AWS ECR 中提取图像时,它会失败并出现以下错误:

ERROR: Preparation failed: API error (500): \
Get https://***.dkr.ecr.***.amazonaws.com/v2/***/manifests/latest: no basic auth credentials

但是我已经使用 ECR 凭据设置了机器,我可以通过 SSH 连接到它,并且两者都可以 root gitlab-runner用户可以拉取图像。直到最近,这一切都可以正常工作,但我不知道可能发生了什么变化。

“没有基本身份验证”甚至意味着什么?

具体来说,这些是我已经完成的步骤:
  • 启动一个普通的 AWS EC2 Linux 实例,并通过 SSH 连接到它

  • 然后:
    sudo su
    echo -e "\n\nexport http_proxy=http://www-proxy.internal.novastone.net:3128\nexport HTTP_PROXY=http://www-proxy.internal.novastone.net:3128\nexport https_proxy=http://www-proxy.internal.novastone.net:3128\nexport HTTPS_PROXY=http://www-proxy.internal.novastone.net:3128" >> ~/.bashrc
    echo -e "\n\nexport http_proxy=http://www-proxy.internal.novastone.net:3128\nexport HTTP_PROXY=http://www-proxy.internal.novastone.net:3128\nexport https_proxy=http://www-proxy.internal.novastone.net:3128\nexport HTTPS_PROXY=http://www-proxy.internal.novastone.net:3128" >> /home/ec2-user/.bashrc
    yum update -y
    yum install -y docker
    mkdir ~/.docker
    echo -e "{\n \"proxies\": {\n \"default\": {\n \"httpProxy\": \"http://***:3128\",\n \"httpsProxy\": \"http://***:3128\"\n }\n }\n}\n"> ~/.docker/config.json
    echo -e "export http_proxy=http://***:3128\nexport HTTP_PROXY=http://***:3128\nexport https_proxy=http://***:3128\nexport HTTPS_PROXY=http://***:3128\n" > /etc/sysconfig/docker
    service docker start
    usermod -a -G docker ec2-user
    docker pull hello-world # To verify basic functionality
    curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | bash
    yum install -y gitlab-ci-multi-runner-1.11.5-1.x86_64
    usermod -a -G docker gitlab-runner
    pip install awscli --upgrade --user
    aws configure
    $(aws ecr get-login --no-include-email --region ***)
    docker pull ***.dkr.ecr.***.amazonaws.com/***:latest # To verify ECR works
    gitlab-ci-multi-runner register
    exit # Drop back to ec2-user
    sudo -u gitlab-runner bash
    echo -e "\n\nexport http_proxy=http://www-proxy.internal.novastone.net:3128\nexport HTTP_PROXY=http://www-proxy.internal.novastone.net:3128\nexport https_proxy=http://www-proxy.internal.novastone.net:3128\nexport HTTPS_PROXY=http://www-proxy.internal.novastone.net:3128" >> /home/gitlab-runner/.bashrc
    aws configure
    $(aws ecr get-login --no-include-email --region ***)
    docker pull ***.dkr.ecr.***.amazonaws.com/***:latest # ECR works here as well

    此时,ECR 图像显示为适用于所有用户。据我所知,通过设置 env,我已经完全绕过了我们的代理。为所有用户永久使用变量,Docker 可以在任何 SSH 情况下正常运行,以及等 no basic auth credentials当 GitLab Runner 参与时仍然存在。为什么?有什么理论吗?感谢所有帮助或想法!

    编辑:FWIW I've also asked on the GitLab forum .

    最佳答案

    拥有 Gitlab 进程的 linux 用户很可能没有所需的凭据。你可以通过运行 sudo -u <username> -H <command> 来测试它。

    或者,您可以通过 --user runner 命令的参数以使用可以登录 ECR 的 linux 用户。

    关于docker - GitLab CI Runner 无法提取私有(private) Docker 镜像 w。 "no basic auth credentials"但它通过 SSH 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49763403/

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