Docker生成错误:没有这样的文件或目录

Docker生成错误:没有这样的文件或目录,docker,Docker,我试图做一个基本的码头工人学习和建立一个形象 我的目录结构当前如下所示: /Documents/docker_test/ ├── docker_python ├── hello_world.py ### Dockerfile # Created by Baktawar # Pulling from base Python image FROM python:3.6.7-alpine3.6 # author of file LABEL maintainer=”Baktawar” #

我试图做一个基本的码头工人学习和建立一个形象

我的目录结构当前如下所示:

/Documents/docker_test/
├── docker_python
├── hello_world.py
### Dockerfile 

# Created by Baktawar

# Pulling from base Python image 

FROM python:3.6.7-alpine3.6

# author of file
LABEL maintainer=”Baktawar”

# Set the working directory of the docker image 
WORKDIR /app
COPY . /app


# packages that we need
RUN pip install numpy && \
    pip install pandas && \
    pip install jupyter


EXPOSE 8888

ENTRYPOINT ["python"]

CMD ["hello_world.py"]
文件
docker\u python
是docker文件名<代码>hello_world.py是一个基本的hello_world python脚本,在为图像创建容器时,默认情况下我会尝试运行它

该docker文件的内容如下所示:

/Documents/docker_test/
├── docker_python
├── hello_world.py
### Dockerfile 

# Created by Baktawar

# Pulling from base Python image 

FROM python:3.6.7-alpine3.6

# author of file
LABEL maintainer=”Baktawar”

# Set the working directory of the docker image 
WORKDIR /app
COPY . /app


# packages that we need
RUN pip install numpy && \
    pip install pandas && \
    pip install jupyter


EXPOSE 8888

ENTRYPOINT ["python"]

CMD ["hello_world.py"]
当我使用

docker_test$ docker build -t docker_python . 

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /Documents/docker_test/Dockerfile: no such file or directory

发生该错误的原因是,默认情况下,docker build需要一个名为Dockerfile的文件。由于您的名为docker_python,因此需要使用--file,-f选项,然后传递文件名

--file , -f     Name of the Dockerfile (Default is ‘PATH/Dockerfile’)

检查以获取更多信息。

发生此错误是因为默认情况下,docker build需要一个名为Dockerfile的文件。由于您的名为docker_python,因此需要使用--file,-f选项,然后传递文件名

--file , -f     Name of the Dockerfile (Default is ‘PATH/Dockerfile’)

查看以获取更多信息。

要使生成立即工作,您的生成命令应为:

docker build -f docker_python -t docker_python . 
默认情况下,build命令将在您提供的生成上下文中查找名为
Dockerfile
的文件(在本例中,您提供
aka.当前工作目录)。如果要覆盖此默认值,请使用-f开关并提供文件名。请注意,
Dockerfile
始终需要位于生成上下文中

docker构建
语法简化:

docker build -f <dockerfile> -t <imagetag> <buildcontext>
如果你想了解更多,这本书值得一读

更新

由于您现在在维护者标签方面遇到了问题,我将在这里为您提供一个完整的Dockerfile:

### Dockerfile 
# Created by Baktawar
# Pulling from base Python image 

FROM python:3.6.7-alpine3.6

# author of file
LABEL maintainer="Baktawar"

# Set the working directory of the docker image 
WORKDIR /app
COPY . /app


# packages that we need
RUN pip install numpy && \
    pip install pandas && \
    pip install jupyter

EXPOSE 8888

ENTRYPOINT ["python"]

CMD ["hello_world.py"]
我只替换了行中的双引号:

LABEL maintainer="Baktawar"
更新

下一个问题似乎是numpy安装。是的,这确实是阿尔卑斯山上的一个已知问题。我通过以下Dockerfile解决了这个问题:

### Dockerfile
# Created by Baktawar
# Pulling from base Python image

FROM python:3.6.7-alpine3.6

# author of file
LABEL maintainer="Baktawar"

# Set the working directory of the docker image
WORKDIR /app
COPY . /app

# Install native libraries, required for numpy
RUN apk --no-cache add musl-dev linux-headers g++

# Upgrade pip
RUN pip install --upgrade pip

# packages that we need
RUN pip install numpy && \
    pip install pandas && \
    pip install jupyter

EXPOSE 8888

ENTRYPOINT ["python"]

CMD ["hello_world.py"]
显然,numpy需要一些本机库才能安装。我还为您升级了pip,我收到了关于该版本的警告

对于你的问题,你应该这样建造:

docker build -f dockerfile -t docker_python .

如果您将
Dockerfile
命名为
Dockerfile
,则答案为“是”。如果您的
Dockerfile
名称准确,则只能使用
-f
开关。它区分大小写。

要使生成立即生效,您的生成命令应为:

docker build -f docker_python -t docker_python . 
默认情况下,build命令将在您提供的生成上下文中查找名为
Dockerfile
的文件(在本例中,您提供
aka.当前工作目录)。如果要覆盖此默认值,请使用-f开关并提供文件名。请注意,
Dockerfile
始终需要位于生成上下文中

docker构建
语法简化:

docker build -f <dockerfile> -t <imagetag> <buildcontext>
如果你想了解更多,这本书值得一读

更新

由于您现在在维护者标签方面遇到了问题,我将在这里为您提供一个完整的Dockerfile:

### Dockerfile 
# Created by Baktawar
# Pulling from base Python image 

FROM python:3.6.7-alpine3.6

# author of file
LABEL maintainer="Baktawar"

# Set the working directory of the docker image 
WORKDIR /app
COPY . /app


# packages that we need
RUN pip install numpy && \
    pip install pandas && \
    pip install jupyter

EXPOSE 8888

ENTRYPOINT ["python"]

CMD ["hello_world.py"]
我只替换了行中的双引号:

LABEL maintainer="Baktawar"
更新

下一个问题似乎是numpy安装。是的,这确实是阿尔卑斯山上的一个已知问题。我通过以下Dockerfile解决了这个问题:

### Dockerfile
# Created by Baktawar
# Pulling from base Python image

FROM python:3.6.7-alpine3.6

# author of file
LABEL maintainer="Baktawar"

# Set the working directory of the docker image
WORKDIR /app
COPY . /app

# Install native libraries, required for numpy
RUN apk --no-cache add musl-dev linux-headers g++

# Upgrade pip
RUN pip install --upgrade pip

# packages that we need
RUN pip install numpy && \
    pip install pandas && \
    pip install jupyter

EXPOSE 8888

ENTRYPOINT ["python"]

CMD ["hello_world.py"]
显然,numpy需要一些本机库才能安装。我还为您升级了pip,我收到了关于该版本的警告

对于你的问题,你应该这样建造:

docker build -f dockerfile -t docker_python .

如果您将
Dockerfile
命名为
Dockerfile
,则答案为“是”。如果您的
Dockerfile
名称准确,则只能使用
-f
开关。它区分大小写。

可能重复Hi的可能重复谢谢。好的,我把这个文件重命名为dockerfile。不需要Dockerfile。不要帽子。但现在我看到了这个错误。步骤2/8:LABEL maintainer=“Baktawar”无法处理“Baktawar\”:在查找匹配的双引号时语句意外结束。请注意,围绕LABEL maintainer=“Baktawar”的双引号不是“犹太”引号。用您自己键入的新双引号替换它们。(我现在也编辑了我的答案-如果你愿意,你可以使用它)好的。现在我不知道为什么在安装numpy时会出现这个错误。--------------------------------------无法从命令/usr/local/bin/python-u-c“导入setuptools,tokenize;uuu文件uu=”/tmp/pip-install-n80erkug/numpy/setup.py';f=getattr(tokenize,'open',open)(文件);code=f.read()。替换('\r\n','n');f.close();exec(编译(代码,文件,'exec')”clean--all:从numpy源目录运行。得到了双引号。它运行,但现在在安装numpy等时出错。请参阅上面的评论和快速问题。当我将其重命名为dockerfile时,为什么需要执行docker build-t docker_python?难道不应该是docker build-t dockerfile?这就是我所做的,而且很有效。谢谢。好的,我把这个文件重命名为dockerfile。不需要Dockerfile。不要帽子。但现在我看到了这个错误。步骤2/8:LABEL maintainer=“Baktawar”无法处理“Baktawar\”:在查找匹配的双引号时语句意外结束。请注意,围绕LABEL maintainer=“Baktawar”的双引号不是“犹太”引号。用您自己键入的新双引号替换它们。(我现在也编辑了我的答案-如果你愿意,你可以使用它)好的。现在我不知道为什么在安装numpy时会出现这个错误。--------------------------------------无法从命令/usr/local/bin/python-u-c“导入setuptools,tokenize;_文件_=”/tmp/pip-install-n80erkug/numpy/setup.py';f=getattr(tokenize,'open',open)(文件);code=f.read()。替换('