在Bitbucket管道中运行Docker

发布于 2025-02-10 11:01:19 字数 1780 浏览 1 评论 0原文

我需要使用- exit-code-from运行Docker-Compose。我当地的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

但是,我需要在Bitbucket管道中运行此操作。为了实现这一点,我使用PIP安装程序安装了Docker-Compose

pip install docker-compose

,它为我提供了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

,此版本可能不荣幸-Exit-code-from,因此

No such service: --exit-code-from

在查看Docker Docs时出现了错误,我发现Compose现在可以在Docker中提供。 CLI本身(尽管从哪个版本开始并不清楚),但是我的Bitbucket管道也不认识到这一点。

+ docker compose help
docker: 'compose' is not a docker command.
See 'docker --help'

这是我的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

任何帮助都将不胜感激!

I need to run docker-compose with --exit-code-from . My local docker-compose binary accepts this command line and works just fine.

+ 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. To achieve that I installed docker-compose using pip installer

pip install docker-compose

Which gives me version 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

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 compose help
docker: 'compose' is not a docker command.
See 'docker --help'

Here is the docker version output inside my bitbucket pipeline

+ 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 !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

聊慰 2025-02-17 11:01:19

由于- 2017年4月推出了选项,因此 v1.12.0 ,我认为Docker-Compose V1 Cli Parser比您在工作站中可能拥有的Docker-Compose V2要挑剔得多。

通过告知没有这样的服务: - exit-code-from错误消息,只需在up up subcmmand之后移动该选项,但在服务列表开始之前:

docker-compose \
  -f file1.yml \
  -f file2.yml \
  up \
    --exit-code-from integration-tests \
    zookeeper-secure kafka-secure schema-registry-secure app integration-tests

非常相关:非常相关: https://stackoverflow.com/59840305/11715259


否则v2在Bitbucket管道中”,这是一个完全不同的主题:

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.

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:

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


Otherwise, this question is about "how to use docker-compose v2 in Bitbucket Pipelines", which is a totally different topic: https://stackoverflow.com/a/73069569/11715259

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文