[英]Run docker compose inside a bitbucket pipeline
I need to run docker-compose with --exit-code-from
.我需要使用
--exit-code-from
运行 docker-compose。 My local docker-compose binary accepts this command line and works just fine.我的本地 docker-compose 二进制文件接受这个命令行并且工作得很好。
+ docker-compose -f file1.yml -f file2.yml up zookeeper-secure kafka-secure schema-registry-secure app integration-tests --exit-code-from integration-tests
However, I need to run this in a bitbucket pipeline.但是,我需要在 bitbucket 管道中运行它。 To achieve that I installed docker-compose using pip installer
为了实现这一点,我使用 pip 安装程序安装了 docker-compose
pip install docker-compose
Which gives me version 1.29.2这给了我 1.29.2 版本
+ docker-compose version
docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.7.12
OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
And this version probably does not honour --exit-code-from and hence errors out而且这个版本可能不尊重 --exit-code-from 并因此出错
No such service: --exit-code-from
While looking into docker docs, i found compose is now available in docker cli itself (though not very clear from which version onwards), but my bitbucket pipeline does not recognise that too.在查看 docker docs 时,我发现 docker cli 本身现在可以使用 compose(虽然从哪个版本开始不太清楚),但我的 bitbucket 管道也无法识别。
+ docker compose help
docker: 'compose' is not a docker command.
See 'docker --help'
Here is the docker version output inside my bitbucket pipeline这是我的 bitbucket 管道中的 docker 版本输出
+ docker version
Client:
Version: 20.10.15
API version: 1.41
Go version: go1.17.9
Git commit: fd82621
Built: Thu May 5 13:10:20 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.15
API version: 1.41 (minimum version 1.12)
Go version: go1.17.9
Git commit: 4433bf6
Built: Thu May 5 13:10:29 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.6.4
GitCommit: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
runc:
Version: 1.1.1
GitCommit: v1.1.1-0-g52de29d7
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Any help will be much appreciated !任何帮助都感激不尽 !
Since the --exit-code-from
option was introduced in April 2017, v1.12.0 , I think the docker-compose v1 CLI parser is being much more picky than the docker-compose v2 you probably have in your workstation.由于
--exit-code-from
选项是在 2017 年 4 月v1.12.0中引入的,我认为 docker-compose v1 CLI 解析器比您可能在工作站中使用的 docker-compose v2 更加挑剔。
Telling by the No such service: --exit-code-from
error message, simply move the option after the up
subcommand but before the service list begins:通过
No such service: --exit-code-from
错误消息来判断,只需将选项移动到up
子命令之后但在服务列表开始之前:
docker-compose \
-f file1.yml \
-f file2.yml \
up \
--exit-code-from integration-tests \
zookeeper-secure kafka-secure schema-registry-secure app integration-tests
Very much related: https://stackoverflow.com/a/59840305/11715259非常相关: https ://stackoverflow.com/a/59840305/11715259
Otherwise, this question is about "how to use docker-compose v2 in Bitbucket Pipelines", which is a totally different topic.否则,这个问题是关于“如何在 Bitbucket Pipelines 中使用 docker-compose v2”,这是一个完全不同的话题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.