微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

来自守护程序的错误响应: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: #

喜欢它不起作用

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

最佳答案
我只是测试了相同,认情况下VSCode似乎用UTF-16 LE编码保存Dockerfile.

文件重新保存为UTF-8允许docker build无错误地运行.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐