1

我正在尝试在我们的企业 Travis CI 实例上通过 Docker Buildx 和 Buildkit 为平台 ppc64le 构建映像。

.travis.yml:

os: linux
dist: bionic
language: shell
branches:
  only:
    - master
before_install:
  - set -e
  # Configure environment so changes are picked up when the Docker daemon is restarted after upgrading
  - echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
  - export DOCKER_CLI_EXPERIMENTAL=enabled
  - sudo rm -rf /var/lib/apt/lists/*
  - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) edge"
  - sudo apt-get update
  - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
  - mkdir -vp ~/.docker/cli-plugins/
  - curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
  - chmod a+x ~/.docker/cli-plugins/docker-buildx
jobs:
  include:
    - stage: build and push docker image
      script:
        - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin  
        - sudo docker buildx build --platform linux/ppc64le --tag myimage:ppc64le -f src/main/docker/Dockerfile.ppc64 --push .

构建将因错误而失败:

$ sudo docker buildx build --platform linux/ppc64le --tag myimage:ppc64le -f src/main/docker/Dockerfile.ppc64 --push .
unknown flag: --platform
See 'docker --help'.
Usage:  docker [OPTIONS] COMMAND

看起来 Buildx 扩展未启用,但 Docker 信息将显示 Experimental_cli 已启用。

关于如何在 Travis 上启用 buildx 的任何想法?

4

1 回答 1

0

我自己遇到了麻烦,但 TravisCI 官方文档指出您需要安装 buildx 插件。这里:https ://www.docker.com/blog/multi-arch-build-what-about-travis/

从我可以看到你在before_install中缺少这个

  - mkdir -vp ~/.docker/cli-plugins/
  - curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
  - chmod a+x ~/.docker/cli-plugins/docker-buildx
于 2020-11-04T13:22:24.540 回答