你能告诉我我是否以正确的方式做:
之前我有 .gitlab-ci.yml
same_task:
stage: deploy
image: python:3
script:
- python -V
Run Code Online (Sandbox Code Playgroud)
我现在有:
pep8:
stage: deploy
image: gitlablogin/projectname
script:
- python -V
Run Code Online (Sandbox Code Playgroud)
在此更改作业失败后:
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)
Run Code Online (Sandbox Code Playgroud)
我在 gitlab CI 和 gitlab 注册表的上下文中使用 docker 是否正确?我还想将我的 docker 文件保留在同一个 repo 上,并在 Dockerfile 中的相同内容发生变化时构建新映像,最好的方法是什么?
要从同一 gitlab 实例上的另一个项目访问 docker 镜像,唯一需要做的是允许您的项目在具有该镜像的项目上进行令牌访问。
不需要其他配置,例如 docker 登录。只需使用image: $CI_REGISTRY/other/project:tag
job-in-project1:
stage: test
image: $CI_REGISTRY/group-b/otherproject:latest
script:
- command to run with docker image
Run Code Online (Sandbox Code Playgroud)
配置:
group-b/otherproject文档:https ://git.aviloo.com/help/ci/jobs/ci_job_token#configure-cicd-job-token-access
现在可以使用 gitlab 注册表中的图像而无需任何特殊步骤。只需构建映像并将其推送到您的 gitlab 项目容器注册表
docker build -t registry.gitlab.com/gitlabProject/projectName:build .
docker push registry.gitlab.com/gitlabProject/projectName:build
Run Code Online (Sandbox Code Playgroud)
然后只需在您的管道设置中指定此图像:
image: registry.gitlab.com/gitlabProject/projectName:build
Run Code Online (Sandbox Code Playgroud)
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 ...
Run Code Online (Sandbox Code Playgroud)
更多:https : //docs.gitlab.com/runner/configuration/advanced-configuration.html#using-a-private-container-registry
您的方法与您想要实现的目标相距不远。我相信你所缺少的是:
根据: https: //docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-an-image
为了使用为 CI 构建的映像,您首先需要将其作为服务添加到运行器的config.toml文件中。
完成后,您就可以使用该指令:image: my_image
但是,您还可以选择另一个选项:您可以登录到 Docker 注册表,拉取并运行 CI Docker 映像,然后您可以在将运行管道的位置执行。
| 归档时间: |
|
| 查看次数: |
4313 次 |
| 最近记录: |