10

Their permission scheme is srwxr-xr-x.

I can't copy them, as I get the following error message.

cp: cannot create special file '/Volumes/Samsung_T5/Dockers/vms/0/00000002.00001003': Operation not permitted

I tried with sudo, but the files are still not copied, although the message is a bit different. This time, it says "Invalid argument."

And yes, I'm trying to move Docker folder to an external disks as it is filling up my hard disk.

0

2 Answers 2

18

This is a (s)ocket type file. As such, it doesn't have any persistent data associated with it and thus it makes no sense to copy it.

Sockets enable communication between two different processes on the same or on different machines. This communication is done using standard Unix/Linux file descriptors, using read() and write() system calls.

4
  • 6
    “it and thus it makes no sense to copy it“ – actually it does. The socket has no content, but its presence and metadata (permissions) are relevant. cp -R should create a socket with identical metadata, but macOS's cp command apparently can't do it. Commented May 15, 2021 at 10:38
  • @Gilles'SO-stopbeingevil' what if the socket is connected to something?
    – OrangeDog
    Commented May 15, 2021 at 13:14
  • 2
    @OrangeDog That's irrelevant. Commented May 15, 2021 at 13:35
  • 3
    @Gilles'SO-stopbeingevil' Is this expected to work on anything except GNU cp? I get the same result on OpenBSD 6.9 amd64.
    – Oskar Skog
    Commented May 15, 2021 at 23:27
15

The first character in the output of ls -l is the type of file: - for a regular file (whatever type its contents is), d for a directory, etc. s indicates a socket, which is a location that programs can use to communicate (a server listens to connections on the socket, and clients can communicate with the server by opening a connection on the socket).

Sockets don't have contents, but their existence is necessary for the software that uses it, and their permissions matter. If software uses a socket, and it doesn't automatically create it when it starts, you need to copy it. (Creating the socket when the server starts is sometimes possible because everything about the socket is well-known, and sometimes not possible because the location and metadata can vary).

There seems to be a bug with macOS's cp command that it doesn't know how to copy sockets. (I get the error “Operation not supported on socket” on Big Sur, so it looks like this is a known limitation, but it's still a bug because cp should be able to copy sockets.) Note that a plain cp copies file contents, but with the option -R or -a, cp should copy special files such as sockets.

You can use the rsync command instead:

rsync -aE /path/to/source/ /path/to/destination/

If you have GNU coreutils installed, its cp command (which may be installed under a different name such as gcp) should be able to do the job as well.

Note that the target drive must use a filesystem that supports special files. You can't run Docker off a FAT/FAT32/exFAT filesystem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .