[英]Use docker image in .gitlab-ci.yml with build essentials and git
Since I want to use docker build
and docker-compose
in gitlab CI, the image should be specified as image: docker:latest
. 由于我想在gitlab CI中使用docker docker build
和docker docker-compose
,因此应该将image: docker:latest
指定为image: docker:latest
。 However, when I run some scripts including git command, it turns out that git and other build-essentials are not included in this image. 但是,当我运行一些脚本(包括git命令)时,事实证明git和其他构建必需项未包含在此映像中。 Even though I use apt-get
, the command is still not found. 即使我使用apt-get
,该命令仍然找不到。
I think the docker image is based on Alpine and apparently uses a different package manager: apk . 我认为docker映像基于Alpine,并且显然使用了不同的软件包管理器: apk 。
So you can: 所以你可以:
apk
instead of apt-get
. 坚持使用docker映像并使用apk
代替apt-get
。 apt-get
. 请改用gitlab / dind:latest映像,因为它基于Ubuntu并包含apt-get
。 In both cases it would be better not to run apt-get
during the build process because it will slow it down and can possibly fail and make your whole build fail. 在这两种情况下,最好不要在构建过程中运行apt-get
,因为这会减慢它的速度,并可能导致整个构建失败。 Instead create your own Docker image based on one of the two images mentioned above and containing the extra tools you need (eg git) and use that own image in .gitlab-ci.yml . 而是根据上述两个映像之一创建您自己的Docker映像,并包含您需要的其他工具(例如git),然后在.gitlab-ci.yml中使用该映像。
FROM gitlab/dind:latest
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y git && \
rm -r /var/lib/apt/lists/*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.