Docker run weirdly slow with volumes containing many files

When i create a new container using docker run the process gets weirdly slow (~ 3+ hours) when this call includes a volume with many small files (~1.5M files, total size 25 gb). The call i am using follows this form:

docker run --name testainer -d -v data:/home/pub -p 3838:3838 image/own

weirdly the container is instantly there (~1 sec) when i mount the corresponding host folder istead of the named volume:

docker run --name testainer -d -v /var/lib/docker/volumes/data/_data:/home/pub -p 3838:3838 image/own

Is there anything i can do to speed up the container creation with named volumes?

I am running coreOS 899.15.0 stable with Docker 1.9.1.

The volume performance issue is a know issue. Refer

I don’t think either of those posts are relevant: the first is specific to boot2docker, and the second the Docker for Mac beta; the OP is running real native Docker on Linux. (Also, the OP finds things go faster using a bind-mounted host directory, which is the opposite of the Docker for Mac giant issue.)

Seeing a copy of the Dockerfile would be helpful. When you say the volume has many small files, do you mean you declare a VOLUME in the Dockerfile and prepopulate it? I think the behavior of those two docker run -v invocations is very different: the first creates a new Docker-internal volume and copies the existing content into it, the second just uses a host directory as is.

That is: I think it’s likely that the time difference is entirely attributable to having to copy those 1.5M files out of the image and into the volume. You might try `docker run -v data:/home/pub:nocopy’ and see if that’s faster, even if it’s missing the content.

(And you probably know this, but it’s generally a bad idea to directly use anything inside the /var/lib/docker tree.)

Could be because of the file size total of 25 GB in the volume. Run the same command but without any files in the volume. Does it still take more than a few seconds?

I edited the first post, because i forgot the colon in the first docker run command. So i am not actually creating a volume, but just linking a named one.

You are absolutely right @dmaze, the posts above are not relevant. I am aware of the boot2docker issue, but this issue here should not be connected to this.

I did not create a VOLUME in a Dockerfile so there is nothing to show here, i just created it manually with docker volume create --name data and created the files while working with another container.

Can you epxplain while the first run command creates an new volume and copies the files - or was this just because of the missing colon? Just to be clear, the files are not part of the image, but reside in the already created named volume.

I tried to run the command with the nocopy flag, but all i get is this:
invalid value "data:/home/pub:nocopy" for flag -v: bad mode specified: nocopy

Mounting from the var/lib/docker tree was only for testing purposes and reference.

@dvohra Mounting an empty volume is of course blazing fast. Why would the size of the volume affect the runtime of the docker runcommand - this seems to be irrelevant when mounting host-directories directly?

In my eyes the behaviour is not reasonable. If i am wrong i would gladly appreciate any explanations - otherwise i am filing a bug report in the github repo.

Mounting an empty volume is of course blazing fast. Why would the size of the volume affect the runtime of the docker runcommand

Because a Docker container has its own filesystem, which limits the size of the volume it is able to mount.

Hi. Where you ever able to find a solution to this?