1.架构不同
我的宿主是x86 ,但是打包的是arm架构
安装qemu
sudo apt-get install binfmt-support qemu qemu-user-static
然后使用buildx打包
docker buildx build --no-cache --platform linux/arm/v7 -t tdc_post:1.0.1 . --load
保存tar
docker save -o tdc_post.tar tdc_post:1.0.0
2. 安装库报错
直接pip3 install -r requestments.txt 的时候报错
修改为执行apt-get install python3-xxx
python
FROM arm32v7/debian AS build
# Run installs
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-utils \
python3 \
python3-pip \
python3-dev \
python3-fastapi \
python3-sqlalchemy
# pip install needed libraries with cert
RUN pip3 install requests --break-system-packages
RUN pip3 install pyyaml --break-system-packages
# Create a directory for the app
WORKDIR /app
# Copy the necessary Python files
COPY . .
# Set the entry point command
CMD ["python3", "start.py"]