【问题标题】:Docker build error, archive/tar: sockets not supportedDocker 构建错误,归档/tar:不支持套接字
【发布时间】:2019-05-20 06:34:42
【问题描述】:

我是 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 有人可以帮我吗?

【问题讨论】:

    标签: linux docker dockerfile


    【解决方案1】:

    您的Dockerfile 可能在/home/shim/ 中?

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

    最佳做法是将 Dockerfile 放在其自己的、隔离的目录中,以避免出现此类情况。

    另外,我建议阅读dockerfile_best-practices,尤其是关于RUNapt-get 的部分

    【讨论】:

      【解决方案2】:

      对于这个特定示例,/home/shim 中不应包含 Dockerfile

      在您项目中的套接字 (*.sock) 文件的一般情况下,您可以将*.sock 添加到您的.dockerignore 文件中。

      【讨论】:

        【解决方案3】:

        您好,我也面临同样的问题,并从这个 Quection 中了解了原因。我的 Dockerfile 在一个步骤中重新启动 MySQL,它创建了一个名为 mysqld.sock 的文件,这是在构建映像时给出的上述错误。 如果这是您的情况,那么您可以在 repo 本身中添加 .sock 文件,然后从那里使用它。

        【讨论】:

          【解决方案4】:

          如果我们在主文件夹中启动命令docker build,则会出现错误。我的 Dockerfile 放在一个子文件夹中,从 /home/$USER 调用 docker build -f /home/$USER/mydocker/Dockerfile 也会导致错误。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多