Gitlab runner:使用自己的(退出)docker 容器
Gitlab runner: Use own (exiting) docker container
我用
注册了一个跑步者
sudo gitlab-ci-multi-runner register
执行器设置为docker
现在要求我提供图片,我选择 ubuntu:16.04
但是我想使用自己的容器,我已经根据需要准备好了。如何使用已经存在的自定义容器?
docker ps
4109775ba06f ubuntu:16.04 "/bin/bash" 25 minutes ago Up 21 minutes want_this_one
Gitlab CI 无法使用已经 运行 的容器。实现此目的的方法是在托管跑步者的机器上以您想要的方式构建图像。
例如,编写包含构建自定义映像所需的所有步骤的 Dockerfile:
FROM ubuntu:16.04
# do all the custom steps here
RUN apt-get update && apt-get install - yq ...
然后使用
构建您的图像
docker build -t custom_image .
另一种方法是将您现有的容器提交到像这样的图像
docker commit 4109775ba06f custom_image
最后在你的.gitlab-ci.yml
中使用你新建的镜像:
image: custom_image
我用
注册了一个跑步者sudo gitlab-ci-multi-runner register
执行器设置为docker
现在要求我提供图片,我选择 ubuntu:16.04
但是我想使用自己的容器,我已经根据需要准备好了。如何使用已经存在的自定义容器?
docker ps
4109775ba06f ubuntu:16.04 "/bin/bash" 25 minutes ago Up 21 minutes want_this_one
Gitlab CI 无法使用已经 运行 的容器。实现此目的的方法是在托管跑步者的机器上以您想要的方式构建图像。
例如,编写包含构建自定义映像所需的所有步骤的 Dockerfile:
FROM ubuntu:16.04
# do all the custom steps here
RUN apt-get update && apt-get install - yq ...
然后使用
构建您的图像docker build -t custom_image .
另一种方法是将您现有的容器提交到像这样的图像
docker commit 4109775ba06f custom_image
最后在你的.gitlab-ci.yml
中使用你新建的镜像:
image: custom_image