来自守护程序的错误响应:Dockerfile 解析错误行 1:未知指令:#

新手上路,请多包涵

我是 docker 新手,正在努力学习它。我正在关注本教程: https ://docs.docker.com/get-started/part2/#apppy

所以我在 Windows 上安装了 Docker。创建了 3 个文件,app.py、Dockefile 和 requirements.txt

我的 docker 文件看起来像这样

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World
CMD ["python", "app.py"]

当我在 powershell 中运行它时

docker build -t friendlybuild .

但结果它给出了这个:

 Error response from daemon: Dockerfile parse error line 1: unknown instruction: #

好像不行

我不知道为什么它不起作用

原文由 Sharpless512 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 863
2 个回答

通过删除 dockerfile 并使用记事本而不是 Visual Code 创建它来解决

原文由 Sharpless512 发布,翻译遵循 CC BY-SA 3.0 许可协议

我忘了在 ENTRYPOINT["java",

应该是 ENTRYPOINT ["java",

原文由 Jöcker 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题