如何使用docker buildx bake为linux/armv7和linux/amd64构建docker compose容器

2024-05-18 08:18:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经用Python开发了一个主要的raspberry pi应用程序,它使用Redis作为其本地缓存,因此我自然转向docker compose来定义我的所有服务,即Redis和我的应用程序。我正在使用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" ]

任何帮助都将不胜感激。谢谢


Tags: thetocomposedockerrunimage命令redis