加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-16 03:45:54 所属栏目:安全 来源:网络整理
导读:我是Docker的新手,并试图学习它. 我遵循这个教程:https://docs.docker.com/get-started/part2/#apppy 所以我在Windows上安装了Docker. 创建了3个文件,app.py,Dockefile和requirements.txt 我的docker文件看起来像这样 # Use an official Python runtime as

我是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无错误地运行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读