你能告诉我我是否以正确的方式做吗?
在我接触过.gitlab-ci.yml
之前same_task:
stage: deploy
image: python:3
script:
- python -V
现在我有
pep8:
stage: deploy
image: gitlablogin/projectname
script:
- python -V
并且此更改作业失败后:
Running with gitlab-runner 11.4.2 (cf91d5e1)
on docker-auto-scale 72989761
Using Docker executor with image gitlablogin/projectname ...
Pulling docker image gitlablogin/projectname ...
ERROR: Job failed: Error response from daemon: pull access denied for gitlablogin/projectname, repository does not exist or may require 'docker login' (executor_docker.go:168:0s)
我在gitlab CI和gitlab注册表中使用docker是否正确?我还想将Docker文件保存在相同的仓库中,并在Dockerfile中进行相同更改时构建新映像,这是最好的方法?
答案 0 :(得分:2)
现在,无需任何特殊步骤即可使用gitlab注册表中的图像。只需构建映像并将其推送到您的gitlab项目容器注册表中
docker build -t registry.gitlab.com/gitlabProject/projectName:build .
docker push registry.gitlab.com/gitlabProject/projectName:build
,然后在管道设置中指定此图像:
image: registry.gitlab.com/gitlabProject/projectName:build
Gitlab能够使用其凭据提取该图像:
Preparing the "docker+machine" executor
00:46
Using Docker executor with image registry.gitlab.com/gitlabProject/projectName:build ...
Authenticating with credentials from job payload (GitLab Registry)
Pulling docker image registry.gitlab.com/gitlabProject/projectName:build ...
Using docker image sha256:e7e0f4f5fa8cff8a93b1f37ffd7dd0505946648246aa921dd457c06a1607304b for registry.gitlab.com/gitlabProject/projectName:build ...
答案 1 :(得分:1)
您的方法离您要实现的目标不远。我相信您所缺少的是:
根据:https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-an-image
为了使用为CI创建的图像,您首先需要将其作为 添加到跑步者的 config.toml 文件中服务 。
完成后,您将可以使用伪指令:image: my_image
但是,还有另一种方法可以执行:您可以登录Docker注册表,提取并运行CI Docker映像,然后可以在运行管道的内部执行。