使用-p的docker登录会产生错误,并且当我切换到--password-stdin之类的建议时,它仍然会给出错误-gitlab-ci [英] docker login using -p gives error, and when I switch to --password-stdin like it recommends still gives error - gitlab-ci

查看:459
本文介绍了使用-p的docker登录会产生错误,并且当我切换到--password-stdin之类的建议时,它仍然会给出错误-gitlab-ci的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gitlab服务器上安装了docker注册表。这是我的.gitlab-ci.yml文件:

 图像:docker:18.05.0-ce 

服务:
-docker:dind

阶段:
-建立
-测试
-释放

变量:
TEST_IMAGE:http://my.gitlab.ip:4444 / path / to / project:$ CI_COMMIT_REF_NAME
RELEASE_IMAGE:http://my.gitlab.ip:4444 / path / to / project:最新

before_script:
-docker login -u $ USERNAME -p $ PASSWORD http://my.gitlab.ip:4444

生成:
阶段:构建
脚本:
-docker构建--pull -t $ TEST_IMAGE。
-docker push $ TEST_IMAGE

#...

#更多命令

我正在为我的用户名和密码使用一个秘密变量。当我推送代码并且运行程序遍历此文件时,出现以下错误:

 警告!通过CLI使用--password是不安全的。使用--password-stdin。 
来自守护程序的错误响应:获取https://my.gitlab.ip:4444 / v2 /:http:服务器对HTTPS客户端


所以我尝试使用-password-stdin 代替:





我收到此错误:

  docker login最多需要1个参数。 
请参阅 docker login --help。

用法:docker login [选项] [服务器] [标志]

编辑:



我也尝试过使用docker登录命令:

  docker登录-u gitlab-ci-token -p $ CI_JOB_TOKEN $ CI_REGISTRY 

并收到此错误:

 警告!通过CLI使用--password是不安全的。使用--password-stdin。 
来自守护程序的错误响应:获取https://my.gitlab.ip:4444 / v2 /:http:服务器对HTTPS客户端


我在gitlab服务器上进行了以下更改:



在/ etc / default / docker中:

  DOCKER_OPTS =-不安全的注册表http://my.gitlab.ip:4444 

在/etc/docker/daemon.json中:

  {
不安全的注册表:[ http://my.gitlab.ip:4444]
}

我也在gitlab运行程序(不同的服务器)上做过同样的事情。



为什么显示我在错误中使用https,如何将其更改为http?

解决方案

我不确定何时设置向上,但是在 GitLab 8.12 之后有一个更新的权限模型,当使用GitLab运行器并登录到GitLab Container注册表时。



作为根据文档,您可以执行以下操作:

  before_script:
-docker login -u gitlab -ci-令牌-p $ CI_JOB_TOKEN $ CI_REGISTRY


I have a docker registry setup on my gitlab server. Here is my .gitlab-ci.yml file:

image: docker:18.05.0-ce

services:
  - docker:dind

stages:
  - build
  - test
  - release

variables:
  TEST_IMAGE: http://my.gitlab.ip:4444/path/to/project:$CI_COMMIT_REF_NAME
  RELEASE_IMAGE: http://my.gitlab.ip:4444/path/to/project:latest

before_script:
  - docker login -u $USERNAME -p $PASSWORD http://my.gitlab.ip:4444

build:
  stage: build
  script:
    - docker build --pull -t $TEST_IMAGE .
    - docker push $TEST_IMAGE

# ...

# more commands

I am using a secret variable for my username and password. When I push code and the runner runs through this file, I get the following error:

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://my.gitlab.ip:4444/v2/: http: server gave HTTP response to HTTPS client

So I tried using --password-stdin instead like this:

And I get this error:

"docker login" requires at most 1 argument.
See 'docker login --help'.

Usage:  docker login [OPTIONS] [SERVER] [flags]

Edit:

I have also tried this for my docker login command:

docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

and received this error:

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://my.gitlab.ip:4444/v2/: http: server gave HTTP response to HTTPS client

I have made the following changes on my gitlab server:

In /etc/default/docker:

DOCKER_OPTS="--insecure-registry http://my.gitlab.ip:4444"

In /etc/docker/daemon.json:

{
    "insecure-registries" : ["http://my.gitlab.ip:4444"]
}

I have also done the same on my gitlab runner (different server).

Why is it showing that I'm using https in the error and how do I change it to http?

解决方案

I'm not sure when you set this up, but there is an updated permission model after GitLab 8.12 when using GitLab runners and logging into the GitLab Container registry.

As per the docs, you can do:

before_script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

这篇关于使用-p的docker登录会产生错误,并且当我切换到--password-stdin之类的建议时,它仍然会给出错误-gitlab-ci的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆