Docker构建未知指令:PYTHON3

2024-05-01 21:52:36 发布

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

我尝试按照docker Hub上的文档构建docker映像。以下是docker图像内容:

FROM alpine:latest
              # This sets the image we start building from
RUN apk add --update \          # first update
   python3 \                    # Install Python
   py-pip \                    # Install pip
 && pip install flywheel-sdk \ # Use pip to install the flywheel SDK
 && rm -rf /var/cache/apk/*    # Cleanup install files

ENV FLYWHEEL=/flywheel/v0
 # Setup default flywheel/v0 directory

RUN mkdir -p ${FLYWHEEL}        # Create that directory
COPY run.py ${FLYWHEEL}/run.py  # Copy in our runscript into the docker image

ENTRYPOINT ["python run.py"]    # Set an entrypoint

当我执行docker build时,我得到一个错误,看起来Python无法从alpine:python映像加载

(base) isabelannwingert@Isabels-MacBook-Pro PET_gear % docker build -t isabelannwingert36/alpine-python-3:0.1.0 ./
Sending build context to Docker daemon  6.144kB
Error response from daemon: Dockerfile parse error line 4: unknown instruction: PYTHON3

当我重新执行docker pull alpine:latest时,它告诉我所有内容都是最新的,但我在Docker Hub上的存储库中也没有看到它

还有什么我可以试试的吗?(我是Docker Hub的新手,请原谅我的天真)


Tags: installpipthedockerrunpyimagebuild
1条回答
网友
1楼 · 发布于 2024-05-01 21:52:36

Docker不支持同一行注释。这就是问题所在。请像这样重写你的代码

# This sets the image we start building from
FROM alpine:latest
# First update, Install Python, Install pip
# Use pip to install the flywheel SDK, Cleanup install files
RUN apk add  update python3 py-pip \
  && pip install flywheel-sdk \
  && rm -rf /var/cache/apk/*

# Setup default flywheel/v0 directory
ENV FLYWHEEL=/flywheel/v0

# Create that directory
RUN mkdir -p ${FLYWHEEL}
# Copy in our runscript into the docker image
COPY run.py ${FLYWHEEL}/run.py

# Set an entrypoint
ENTRYPOINT ["python run.py"]

相关问题 更多 >