[英]How to use docker buildx bake to build docker compose containers for both linux/armv7 and linux/amd64
I have developed a primarily raspberry pi app in Python that uses Redis as its local cache so naturally I turned to docker compose to define all my services ie redis and my app. 我正在使用 Docker Hub 私有存儲庫來托管我的容器。 但我不知道如何使用docker buildx bake
命令來定位 linux/armv7 平台,因為--platform
標志不是bake
的一部分
Docker 團隊展示的所有示例都使用了簡單的docker buildx
命令,該命令無法用於撰寫文件。
我的 docker-compose.yml 文件定義為:
version: '3.0'
services:
redis:
image: redis:alpine
app:
image: dockerhub/repository
build: gateway
restart: always
Dockerfile:
# set base image (Host OS)
FROM python:3.8-slim
# set the working directory in the container
WORKDIR /run
# copy the dependencies file to the working directory
COPY requirements.txt .
# install dependencies
RUN pip install -r requirements.txt
# copy the content of the local src directory to the working directory
COPY src/ .
# command to run on container start
CMD [ "python", "-u", "run.py" ]
任何幫助將非常感激。 謝謝
您可以在關鍵 xbake 下提供平台參數,如下所述。 (參考文檔: https://docs.docker.com/engine/reference/commandline/buildx_bake/ )
# docker-compose.yml
services:
addon:
image: ct-addon:bar
build:
context: .
dockerfile: ./Dockerfile
args:
CT_ECR: foo
CT_TAG: bar
x-bake:
tags:
- ct-addon:foo
- ct-addon:alp
platforms:
- linux/amd64
- linux/arm64
cache-from:
- user/app:cache
- type=local,src=path/to/cache
cache-to: type=local,dest=path/to/cache
pull: true
aws:
image: ct-fake-aws:bar
build:
dockerfile: ./aws.Dockerfile
args:
CT_ECR: foo
CT_TAG: bar
x-bake:
secret:
- id=mysecret,src=./secret
- id=mysecret2,src=./secret2
platforms: linux/arm64
output: type=docker
no-cache: true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.