Docker 构建错误,存档/tar:不支持套接字

Shi*_*ner 3 linux docker dockerfile

我是 Docker 的新手,正在尝试构建映像。我使用 Docker commit 命令成功地做到了这一点,但是当我尝试使用 Dockerfile 做到这一点时,我收到以下错误:

shim@shim-Inspiron-5570:~$ sudo docker build -t shim/debian .
[sudo] password for shim: 
ERRO[0014] Can't add file /home/shim/.ServiceHub/bc1be858c1/116f2fb4b7 to tar: archive/tar: sockets not supported 
ERRO[0014] Can't add file /home/shim/.ServiceHub/bc1be858c1/11a6628921 to tar: archive/tar: sockets not supported 
ERRO[0014] Can't add file /home/shim/.ServiceHub/bc1be858c1/2cb20241cd to tar: archive/tar: sockets not supported 
ERRO[0014] Can't add file /home/shim/.ServiceHub/bc1be858c1/4964606154 to tar: archive/tar: sockets not supported 
ERRO[0014] Can't add file /home/shim/.ServiceHub/bc1be858c1/bc1be858c1 to tar: archive/tar: sockets not supported 
^Cnding build context to Docker daemon  1.725GB
Run Code Online (Sandbox Code Playgroud)

Docker 文件如下所示:

FROM debian:shim
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y vim
Run Code Online (Sandbox Code Playgroud)

我正在使用 Ubuntu DeskTop 18.04 可以有人帮我吗?

SiH*_*iHa 10

看起来你Dockerfile可能在/home/shim/?

执行此操作后docker build .,docker 将压缩当前目录的内容并将其发送到 docker 守护进程。它看起来像一些文件/home/shim/.ServiceHub实际上是套接字,所以这个操作失败了。

最佳实践是将 Dockerfile 放在它自己的、独立的目录中,以避免出现这样的事情。

另外,我建议通读dockerfile_best-practices,特别是关于RUN&apt-get