我是 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
Docker 文件如下所示:
FROM debian:shim
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y vim
我使用的是 Ubuntu DeskTop 18.04 有人可以帮助我吗?
最佳答案
看起来你的 Dockerfile
可能在 /home/shim/
中?
当您执行 docker build .
时,docker 会压缩当前目录的内容并将其发送到 docker 守护进程。看起来/home/shim/.ServiceHub
中的一些文件实际上是套接字,所以这个操作失败了。
最佳做法是将 Dockerfile 放在它自己的、隔离的目录中,以避免出现此类情况。
此外,我建议通读 dockerfile_best-practices ,特别是关于 RUN
和 apt-get
关于linux - Docker 构建错误,存档/tar : sockets not supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56215440/