如何解决如何在 docker buildx
我想用 buildx 构建一个多架构映像。这是我的 GitLab CI 管道。第一步,我构建codebase:latest 图像。此映像的构建过程很困难,但最终仅包含静态文件。我想在构建 $CI_REGISTRY_IMAGE/Nginx:latest 和 $CI_REGISTRY_IMAGE/PHP:latest 图像时使用这些文件。
当我使用简单的 docker build 时,它的工作正常:
# Part of ./.deploy/Nginx/Dockerfile
copY --from=codebase /app/public /app/public
但是,当我使用 buildx 时出现错误。
我该如何解决这个问题?
Dockerfile:5
--------------------
3 | copY app.conf /etc/Nginx/conf.d/default.conf
4 | copY Nginx.conf /etc/Nginx/Nginx.conf
5 | >>> copY --from=codebase /app/public /app/public
6 | workdir /app
7 |
--------------------
error: Failed to solve: rpc error: code = UnkNown desc = Failed to load cache key: pull access denied,repository does not exist or may require authorization: server message: insufficient_scope: authorization Failed
.gitlab-ci.yml
stages:
- buildx
- deploy-images
buildx:
image: docker:19.03-git
stage: buildx
variables:
GIT_STRATEGY: none
DOCKER_TLS_CERTDIR: ''
DOCKER_DRIVER: overlay2
artifacts:
paths:
- buildx
expire_in: 1 hour
services:
- docker:19.03-dind
script:
- export DOCKER_BUILDKIT=1
- git clone git://github.com/docker/buildx ./docker-buildx
- docker build --platform=local -o . ./docker-buildx
deploy-images:
stage: deploy-images
image: docker:19.03.5
services:
- name: docker:19.03.5-dind
command: ["--experimental"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
CI_BUILD_ARCHS: "linux/amd64,linux/arm64"
before_script:
- mkdir -p ~/.docker/cli-plugins
- mv buildx ~/.docker/cli-plugins/docker-buildx
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker buildx create --use --name mybuilder
script:
- docker buildx build --platform "$CI_BUILD_ARCHS" -f ./.deploy/codebase/Dockerfile -t codebase:latest .
- docker buildx build --platform "$CI_BUILD_ARCHS" --push -t $CI_REGISTRY_IMAGE/Nginx:latest ./.deploy/Nginx/.
- docker buildx build --platform "$CI_BUILD_ARCHS" --push -t $CI_REGISTRY_IMAGE/PHP:latest ./.deploy/PHP/.
only:
- master
./.deploy/Nginx/Dockerfile
FROM Nginx:alpine
copY app.conf /etc/Nginx/conf.d/default.conf
copY Nginx.conf /etc/Nginx/Nginx.conf
copY --from=codebase /app/public /app/public
workdir /app
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。