GitLab CI 对 Docker 构建作业的无效参数 [英] GitLab CI invalid argument on job for Docker build

查看:13
本文介绍了GitLab CI 对 Docker 构建作业的无效参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试设置我的 Gitlab CI 以触发 git push 上的作业以构建和部署我的 Docker.这是我使用的 .gitlab-ci.yml 文件,基于 Gitlab 文档 (Elixir yml) 中的示例.

So I'm trying to setup my Gitlab CI to trigger a job on git push to build and deploy my Docker. This is the .gitlab-ci.yml file I'm using based on an example from Gitlab docs (Elixir yml).

stages:
  - build

build:
  before_script:
    - docker build -f Dockerfile.build -t ci-project-build-$CI_PROJECT_ID:$CI_BUILD_REF .
    - docker create
      -v /build/deps 
      -v /build/_build
      -v /build/rel
      -v /root/.cache/aceapp/
      --name build_data_$CI_PROJECT_ID_$CI_BUILD_REF busybox /bin/true
  tags:
    - docker
  stage: build
  script: 
    - docker run --volumes-from build_data_$CI_PROJECT_ID_$CI_BUILD_REF --rm -t ci-project-build-$CI_PROJECT_ID:$CI_BUILD_REF

推送到 GitLab 实例时的输出是这样的:

The output when pushing to GitLab instance is this:

Running with gitlab-runner 10.7.2 (b5e03c94)
on my.host.rhel.runner 8f724ea7
Using Shell executor...
Running on my.host.local...
Fetching changes...
HEAD is now at 14351c4 Merge branch 'Development' into 'master'
From https://my.host.example/zalmosc/ace-app
   14351c4..9fa2d43  master     -> origin/master
Checking out 9fa2d435 as master...
Skipping Git submodules setup
$ # Auto DevOps variables and functions # collapsed multi-line command
$ setup_docker
$ build
Logging to GitLab Container Registry with CI credentials...
Login Succeeded

Building Dockerfile-based application...
invalid argument "/master:9fa2d4358e6c426b882e2251aa5a49880013614b" for t: Error parsing reference: "/master:9fa2d4358e6c426b882e2251aa5a49880013614b" is not a valid repository/tag: invalid reference format
See 'docker build --help'.
ERROR: Job failed: exit status 1

我了解 docker 标签无效(before_script: 真的是根据名称触发的吗?),我正在寻求有关 a) 解决方案 b) 我如何学习的帮助更多关于基于默认设置构建 docker 的管道的要求.我是否需要在本地标记我的 docker 映像,然后以某种方式将其添加到我的 git 提交中?

I understand the docker tag is not valid (is the before_script: really triggered based on the name?), and I'm looking for help regarding a) a solution b) how I can learn more about the requirements for a pipeline that builds docker based on default settings. Do I need to tag my docker image locally and then somehow add this to my git commit?

推荐答案

-t 就是标记你的 Docker 镜像.查看文档这里.

The thing is -t is to tag your Docker image. See the docs here.

标签的格式应该像 name:version,并且你给它 /master:9fa2d4358e6c426b882e2251aa5a49880013614b 这不是一个有效的标签.您可以尝试在 master

The tag should be formated like name:version, and you giving it /master:9fa2d4358e6c426b882e2251aa5a49880013614b which is not a valid tag. You could try to delete the / before master

这篇关于GitLab CI 对 Docker 构建作业的无效参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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