Shimon Wiener
Shimon Wiener

Reputation: 1180

Docker build error, archive/tar: sockets not supported

I'm new to Docker and trying to build an image. I succeeded in doing that with the Docker commit command, but when I'm trying to do it with Dockerfile I get this errors:

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

The Docker file looks like this:

FROM debian:shim
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y vim

I'm using Ubuntu DeskTop 18.04 Can some one help me with it?

Upvotes: 13

Views: 15431

Answers (5)

Khalid
Khalid

Reputation: 367

Maybe this answer is late , but in my case the cause was the same project is open in visual studio , so only closing that did the trick for me

Upvotes: -1

ywiyogo
ywiyogo

Reputation: 856

The errors appear if we start the command docker build in the home folder. My Dockerfile is placed in a subfolder, and calling docker build -f /home/$USER/mydocker/Dockerfile from /home/$USER will cause the error too.

Upvotes: -1

png
png

Reputation: 6570

For this particular example, you should not have Dockerfile in /home/shim.

In the general case of a socket (*.sock) file in your project, you can add *.sock to your .dockerignore file.

Upvotes: 4

vipin yadav
vipin yadav

Reputation: 68

Hi I also face the same issues and got to know the reason from this Quection. My Dockerfile is restarting MySQL in a step and it creates a file called mysqld.sock which is a giving above error while building image. If that is your case then you can add .sock file in repo itself and then use it from there.

Upvotes: 0

SiHa
SiHa

Reputation: 8421

It looks like your Dockerfile is probably in /home/shim/?

When you do docker build ., docker will tar up the contents of the current directory and send it to the docker daemon. It looks like some of the files in /home/shim/.ServiceHub are actually sockets, so this operation fails.

Best practice is to have the Dockerfile in its own, isolated, directory to avoid stuff like this.

Also, I suggest having a read through dockerfile_best-practices, in particular the bit about RUN & apt-get

Upvotes: 15

Related Questions