[英]Use docker without registry for gitlab-ci
My school has a personal gitlab setup, but it doesn't have a registry setup for docker images.我的学校有个人 gitlab 设置,但没有 docker 镜像的注册表设置。
What I want to do is run my pipeline with docker, so that I can build, test etc in a docker environment.我想要做的是使用 docker 运行我的管道,以便我可以在 docker 环境中构建、测试等。
Right now i am trying random stuff because I don't know what I am doing.现在我正在尝试随机的东西,因为我不知道我在做什么。 This is what I have now:这就是我现在所拥有的:
Gitlab-ci: Gitlab-ci:
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build-master:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
build:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
My secret variables on gitlab:我在 gitlab 上的秘密变量:
My error message in the pipeline:我在管道中的错误消息:
Something else I tried uses a gitlab repo.我尝试过的其他方法使用 gitlab 存储库。 This uses the docker image for ros correctly, but in my application I also use opencv, so I want to add more to the docker image.这正确地使用了 ros 的 docker 镜像,但是在我的应用程序中我也使用了 opencv,所以我想在 docker 镜像中添加更多。 If i know how to do that in the example below, thats also an option.如果我知道如何在下面的示例中做到这一点,那也是一种选择。 On top of this, in the example below i can't run tests.最重要的是,在下面的示例中,我无法运行测试。
Gitlab-ci: Gitlab-ci:
image: ros:kinetic-ros-core
stages:
- build
variables:
ROS_PACKAGES_TO_INSTALL: ""
USE_ROSDEP: "true"
cache:
paths:
- ccache/
before_script:
- git clone https://gitlab.com/VictorLamoine/ros_gitlab_ci.git
- source ros_gitlab_ci/gitlab-ci.bash
catkin_make:
stage: build
script:
- catkin_make
catkin_build:
stage: build
script:
- catkin build --summarize --no-status --force-color
As I said I have tried many things, this is just the latest thing I have tried.正如我所说,我尝试了很多东西,这只是我尝试过的最新东西。 How can I run my runners and gitlab-ci with docker without a gitlab registry?如何在没有 gitlab 注册表的情况下使用 docker 运行我的跑步者和 gitlab-ci?
Just use it withouth registry.只需在没有注册表的情况下使用它。 You just need to insert this to gitlab runner config file:您只需要将其插入到 gitlab runner 配置文件中:
pull_policy = "if-not-present" pull_policy = "如果不存在"
Thats enough, and remove commands like:够了,然后删除以下命令:
docker push ...码头推...
docker pull ...码头拉...
Or even insert "|| true" at the end of the push pull command if you want to keep push pull in case, like this:或者甚至在 push pull 命令的末尾插入“|| true”,如果你想保持 push pull 以防万一,像这样:
docker pull ... ||码头工人拉... || true;真的;
Which keeps your code to continue if command fail.如果命令失败,这将使您的代码继续。 Just dont forget that : pull_policy = "if-not-present" , which allow You to run docker image withouth pull and push.只是不要忘记: pull_policy = "if-not-present" ,它允许您在没有拉和推的情况下运行 docker 镜像。 As image is in case if mussing builded, this works.由于图像是在构建 mussing 的情况下,这是有效的。
example:例子:
[[runners]]
name = "Runner name"
url = ...
...
executor = "docker"
[runners.docker]
image = ...
pull_policy = "if-not-present"
...
You can change these secret variables to point to docker-hub registry server.您可以更改这些秘密变量以指向 docker-hub 注册表服务器。
You have to create your account on that https://hub.docker.com/ and then use that details to configure - gitlab secret variables.您必须在该https://hub.docker.com/上创建您的帐户,然后使用该详细信息来配置 - gitlab 秘密变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.