`sudo docker build .` 从 Docker snap 包失败

`sudo docker build .` fails from Docker snap package

我 运行 Ubuntu 16.04 并且我已经通过快照包安装了 docker。 docker build 无法访问我的 Dockerfile,它设置在 ~.

的子目录中

snap 接口似乎连接正确...

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

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

$ 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 的新手,有什么我遗漏的吗?

以下是 Docker 文件的内容:

# 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

NOTE: I have confirmed docker build . -t serial-wiring.base works using this Dockerfile on Windows.

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

获得一些关于如何解决(即打破)限制模型直到正确修复到位的有用说明。您可以简单地查看快照中打包的 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 现在可以正常运行。