【问题标题】:`sudo docker build .` fails from Docker snap package`sudo docker build .` 从 Docker snap 包失败
【发布时间】:2017-09-30 05:33:33
【问题描述】:

我运行 Ubuntu 16.04,并通过 snap 包安装了 docker。 docker build 无法访问我的Dockerfile,它设置在~ 的子目录中。

snap 界面似乎已正确连接...

$ snap interfaces
Slot    Plug
...
:home   docker
...

但是,当我调用docker build从包含Dockerfile的目录)时,我收到以下错误...

$ sudo docker build . -t serial-wiring.base
unable to prepare context: unable to evaluate symlinks in context path: lstat /home/<username>/Documents: permission denied

我是 Docker 新手,有什么我缺少的吗?

这里是 Dockerfile 的内容:

# Base Image
FROM ubuntu

# Add Required Packages [Layer 1]
RUN apt update && \
    apt install -y ca-certificates cmake g++ git make --no-install-recommends

# Download Sources [Layer 2]
RUN cd ~ && \
    git clone https://github.com/remote-wiring/serial-wiring.git && \
    cd serial-wiring/ && \
    mkdir build

# Verify Build and Install
CMD cd ~/serial-wiring/build/ && \
    cmake .. && \
    make

注意:我已经确认 docker build . -t serial-wiring.base 可以在 Windows 上使用这个 Dockerfile。

【问题讨论】:

  • 如果 Dockerfile 不在您运行它的目录中 (docker build .),您需要提供它所在目录的路径。上下文位于选项之后:@ 987654332@
  • @meatspace 他们在最近的版本中对参数解析做了一些改进,我认为这是修复的命令之一(re: context after options)
  • 澄清一下,Dockerfile 位于我调用docker build 的目录中。我会更新问题...

标签: docker snapcraft


【解决方案1】:

由于不断发展的 snappy 模型中的限制问题,Docker 默认情况下并不完整 (see the discussion on the Snapcraft forum)。

获取有关如何解决(即打破)限制模型的有用说明,直到适当的修复到位。您可以简单地查看打包在 snap 中的 Docker 帮助应用程序。

$ docker.help
Docker snap: Docker Linux container runtime.

Due to the confinement issues on snappy, it requires some manual setup to make docker-snap works on your machine.
We'll take you through the steps needed to set up docker snap work for you on ubuntu core and ubuntu classic.

On Ubuntu classic, before installing the docker snap, 
please run the following command to add the login user into docker group.
    sudo addgroup --system docker
    sudo adduser $USER docker
    newgrp docker

On Ubuntu Core 16, after installing the docker snap from store,
Firstly, you need to connect the two interfaces as they're not auto-connected by default.
    sudo snap connect docker:account-control :account-control
    sudo snap connect docker:home :home

Secondly, reload the snap and allows the user to login to the new group "docker-snap".
    snap disable docker
    snap enable  docker
    newgrp docker-snap

Then have fun with docker in snappy.

最后一条命令失败...

$ newgrp docker-snap
newgrp: group 'docker-snap' does not exist

但是,我没有注意到失败带来的任何负面影响,Docker 现在可以正常运行。

【讨论】:

    猜你喜欢
    • 2021-03-06
    • 1970-01-01
    • 2018-01-20
    • 1970-01-01
    • 2017-05-29
    • 1970-01-01
    • 2020-09-14
    • 2019-08-23
    • 2023-01-11
    相关资源
    最近更新 更多