docker - Docker 错误:错误检查上下文:'can't stat '/home/xyz/docker_experiments''
问题描述
我在 Ubuntu 机器上运行 docker [Docker version 17.06.2-ce, build 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"]
解决方案
可能是权限问题。
您可以尝试 2 件事:
- 尝试删除 sudo。如果您在安装 Docker 时已正确配置它,则不需要在每个命令上都使用 sudo。如果我开始工作后遇到这个问题,我可以用代码更新这个答案。
- 尝试将您的 dockerfile 从您的 ubuntu 目录移出到您已设置并有权访问的目录中。尝试 chmodding 该目录,以便您拥有所需的所有访问权限。
mkdir /docker/test
cp . /docker/test
cd /docker/test
sudo docker build -t friendlyhello .
推荐阅读
- sql - 使用 UNION ALL 和 RANK 优化 Hive 查询
- javascript - 如何获得不同颜色的字符串
- c# - 为 .NET Framework 接口实现接口隔离原则
- javascript - highcharter:在股票图中捕获当前选定的最小和最大日期
- sql - 具有动态列和 JOINS 5+ 表的 PIVOT
- bash - 将字符串作为参数发送到 bash 脚本以使用 Git Alias 自动执行 Git 命令
- mysql - 为什么 MySQL 在其内部表示中打包日期类型
- ios - iOS 部署目标设置为 7.0,但此平台支持的部署目标版本范围为 8.0 到 12.1。(在目标“反应”中)
- java - 我想在 java 中读取和修改一个 .xlsm 文件,我正在使用 Apache POI。在写入 .xlsm 文件时,我的代码正在创建 0 kb 文件
- javascript - 获取在 Chrome 扩展中执行脚本的选项卡的选项卡 ID