我正在尝试构建一个提供静态html的简单docker容器.我有以下Dockerfile:
FROM ubuntu
# Install python3
RUN apt-get update
RUN apt-get install -y python3
# Copy html
ADD static/ /src
RUN cd /src
# Run http server on port 8080
EXPOSE 8080
CMD ["python3","-m http.server 8080"
但是,当我构建运行它时,我收到以下错误:
/usr/bin/python3: No module named http
我通过交互式shell尝试了相同的步骤,它们工作正常,但是一旦我使用Dockerfile就失败了.
我认为您的CMD语法错误.我刚试过,它工作正常:
FROM ubuntu
# Install python3
RUN apt-get update
RUN apt-get install -y python3
# Copy html
ADD static/ /src
RUN cd /src
# Run http server on port 8080
EXPOSE 8080
CMD ["python3","-m","http.server","8080"]