【问题标题】:Docker Errors : error checking context: 'can't stat '/home/xyz/docker_experiments''Docker 错误:错误检查上下文:'can't stat '/home/xyz/docker_experiments''
【发布时间】:2018-10-04 05:48:02
【问题描述】:

我在 Ubuntu 机器上运行 docker [Docker 版本 17.06.2-ce,构建 a04f55b]。

只需从 docker 执行一个非常简单的练习即可构建 docker 映像:https://docs.docker.com/get-started/part2/#apppy

在运行以下命令时

sudo docker build -t friendlyhello .

我收到以下错误

error checking context: 'can't stat '/home/xyz/docker_experiments''.

我知道这与 apparmour 和权限有关。

根据要求,这是 Dockerfile

# 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
COPY . /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

# Run app.py when the container launches
CMD ["python", "app.py"]

【问题讨论】:

  • 您能否在问题中包含您正在使用的实际 Dockerfile?

标签: docker dockerfile ubuntu-18.04


【解决方案1】:

可能是权限问题。

您可以尝试 2 件事:

  • 尝试删除 sudo。如果您在安装 Docker 时已正确配置它,则不需要在每个命令上都使用 sudo。如果我开始工作后遇到这个问题,我可以用代码更新这个答案。
  • 尝试将 dockerfile 从 ubuntu 目录移到您已设置并有权访问的目录中。尝试 chmodding 该目录,以便您拥有所需的所有访问权限。

mkdir /docker/test cp . /docker/test cd /docker/test sudo docker build -t friendlyhello .

【讨论】:

  • 谢谢。这是一个简单的权限问题。在提升权限的用户下创建新目录有效
猜你喜欢
  • 2017-05-08
  • 2019-06-21
  • 1970-01-01
  • 2019-01-24
  • 2021-06-08
  • 2012-05-03
  • 1970-01-01
  • 1970-01-01
  • 2015-01-05
相关资源
最近更新 更多