Slow disk performance in Docker container

Problem

I have some extremely slow disk IO within a Docker container. I'm using Boot2Docker, so i'm actually now wondering if the issue is vboxsf?

Testing

I used this script initially because I was debugging a web app but it seems it's the disk read itself.

  • Within Docker: 1.6156311035156
  • Host: 0.022423028945923

I tested the disk speed with dd and the results within the container:

$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=25000 && sync"; rm ddfile
25000+0 records in
25000+0 records out
204800000 bytes (205 MB) copied, 4.23099 s, 48.4 MB/s

real    0m4.241s
user    0m0.000s
sys 0m2.110s

And on the host:

$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=25000 && sync"; rm ddfile
25000+0 records in
25000+0 records out
204800000 bytes transferred in 0.482290 secs (424640750 bytes/sec)
sh -c "dd if=/dev/zero of=ddfile bs=8k count=25000 && sync"  
0.01s user 0.30s system 48% cpu 0.650 total

The host outputted in bytes and the container in mbs, but converting those numbers, the speed difference is about 10 times the speed.

I'm using Docker's -v host/folder:container:/folder to mount the codebase into the container. I'm not really sure where to go from here. Is there some known issues with Docker mounts? Or could there be another issue at play?


so you are using a mac. That means you are installing docker on virtualbox.. so here's how storage goes

os x -> virtualbox vm -> linux FS of choice -> aufs -> docker

So you are adding another VM layer on top of what docker already has on it.

I don't think anyone has claimed docker IO will perform close to what you see on the host.


The issue is vboxsf, not docker. Spent days playing with this. vboxsf is incredibly incredibly slow. NFS is faster, depends what you're wanting to do though.

I decided I don't need the files on my host anyway, so subsequently just created a new virtual disk in my vagrant file which is where my source gets cloned to, and then I just back that file up.

This is hard to do with boot2docker I found, so I just use virtual box and vagrant with an image I made, hp-ess/docker which has the latest docker and docker compose in.