在.gitlab-ci.yml中运行docker-compose build [英] Run docker-compose build in .gitlab-ci.yml

查看:272
本文介绍了在.gitlab-ci.yml中运行docker-compose build的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .gitlab-ci.yml 文件,其中包含以下内容:

I have a .gitlab-ci.yml file which contains following:

image: docker:latest

services:
  - docker:dind

before_script:
  - docker info
  - docker-compose --version

buildJob:
  stage: build
  tags:
    - docker
  script:
    - docker-compose build

但是在 ci-log 我收到消息:



$ docker-compose --version
/bin/sh: eval: line 46: docker-compose: not found

什么是我做错了吗?

推荐答案

编辑我添加了另一个答案,为.gitlab- ci.yml配置支持docker-compose。

EDIT I added another answer providing a minimal example for a .gitlab-ci.yml configuration supporting docker-compose.

docker-compose 可以作为Python软件包安装,该软件包不随映像一起提供。您选择的映像甚至不提供Python安装:

docker-compose can be installed as a Python package, which is not shipped with your image. The image you chose does not even provide an installation of Python:

$ docker run --rm -it docker sh
/ # find / -iname "python"
/ # 

查找Python会给出一个空结果。因此,您必须选择适合您需要的其他映像,并且理想情况下已安装docker-compose或您手工创建了一个。

Looking for Python gives an empty result. So you have to choose a different image, which fits to your needs and ideally has docker-compose installed or you maually create one.

您选择的Docker映像使用Alpine Linux 。您可以将其用作自己的映像的基础,如果您不熟悉Alpine Linux,可以先尝试使用其他映像。

The docker image you chose uses Alpine Linux. You can use it as a base for your own image or try a different one first if you are not familiar with Alpine Linux.

我遇到了同样的问题,并创建了一个Dockerfile在公共GitHub存储库中并将其与我的Docker Hub帐户关联,并选择自动构建以在每次推送到GitHub存储库时构建我的映像。然后,您可以使用GitLab CI轻松访问自己的图像。

I had the same issue and created a Dockerfile in a public GitHub repository and connected it with my Docker Hub account and chose an automated build to build my image on each push to the GitHub repository. Then you can easily access your own images with the GitLab CI.

这篇关于在.gitlab-ci.yml中运行docker-compose build的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆