Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Volumes Slow #188

Closed
dimasnake opened this issue Nov 1, 2016 · 181 comments
Closed

Shared Volumes Slow #188

dimasnake opened this issue Nov 1, 2016 · 181 comments

Comments

@dimasnake
Copy link

Expected behavior

File access in volumes should be comparable to access times in non-volumes, similarly to Linux installations of docker

Actual behavior

File access in volumes is many times slower than on non-volumes.

Information

Version: 1.12.3-beta29.2 (8280)
Channel: Beta
Sha1: 902414df0cea7fdc85b87f0077b0106c3af9f64c
Started on: 2016/11/01 21:19:46.408
Resources: C:\Program Files\Docker\Docker\Resources
OS: Windows 10 Pro
Edition: Professional
Id: 1607
Build: 14393
BuildLabName: 14393.351.amd64fre.rs1_release_inmarket.161014-1755

Steps to reproduce the behavior

Get on the commandline of a lightweight docker container

root@a6b2e82c167b:/# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 0.569183 s, 180 MB/s

and mount a volume:

root@a6b2e82c167b:/var/www# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 5.11662 s, 20.0 MB/s

In 9 times slower.

@friism
Copy link

friism commented Nov 1, 2016

Thanks for reporting. The volume mounts are implemented using a SMB share mounted over the guest/host network.

Out of curiosity, what's your development use-case that requires greater than 20 MB/s transfer-rate when using volumes?

@dimasnake
Copy link
Author

I use docker for local web development. I have nginx, php-fpm, mysql containers. Speed website pages load very slow 5-10 sec.

It is possible to encrease volumes speed?

@xdesbieys
Copy link

I have same problem.

Inside container :

root@63d3c3f00862:/# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 0.208075 s, 492 MB/s

Insidde container share folder :

root@63d3c3f00862:/var/lib/mysql# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 11.572 s, 8.8 MB/s

Docker info :

PS C:\Users\????\Docker> docker info
Containers: 4
 Running: 4
 Paused: 0
 Stopped: 0
Images: 11
Server Version: 1.12.3
Storage Driver: overlay2
 Backing Filesystem: extfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.27-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.919 GiB
Name: moby
ID: DBIQ:SFE4:ZUSS:AEDJ:4KJC:ODIJ:W4L7:33D7:QUB7:OE4R:YEIE:UANK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 41
 Goroutines: 78
 System Time: 2016-11-02T12:20:15.4120124Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
WARNING: No kernel memory limit support
Experimental: true
Insecure Registries:
 127.0.0.0/8

Docker volume inspect :

PS C:\Users\????\Docker> docker volume inspect 7c27e585d8d4f55c34a34f6a47d5c0687f0851fc55765b096183f6ee327ea609
[
    {
        "Name": "7c27e585d8d4f55c34a34f6a47d5c0687f0851fc55765b096183f6ee327ea609",
        "Driver": "local",
        "Mountpoint": "/var/lib/docker/volumes/7c27e585d8d4f55c34a34f6a47d5c0687f0851fc55765b096183f6ee327ea609/_data",
        "Labels": null,
        "Scope": "local"
    }
]

Docker compose :

version: "2"
services:
    mysql:
        image: mysql:latest
        volumes:
            - ./mysql:/var/lib/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=password
            - MYSQL_DATABASE=database
            - MYSQL_USER=user
            - MYSQL_PASSWORD=password
        ports:
            - "3306:3306"
    php:
        build: ./php
        image: php:fpm
        ports:
            - "9000:9000"
        links:
            - mysql
    nginx:
        build: ./nginx
        image: nginx:latest
        volumes:
            - ./nginx/website.conf:/etc/nginx/conf.d/website.conf
        ports:
            - "80:80"
        links:
            - php
    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        environment:
            - PMA_HOST=mysql
            - MYSQL_USERNAME=user
            - MYSQL_ROOT_PASSWORD=password
        ports:
            - "8181:80"
        links:
            - mysql

Is it possible to use NFS of other file sharing system ?

@BlueBeN82
Copy link

Same usecase and behavior for me.

@fmasa
Copy link

fmasa commented Nov 22, 2016

@friism One of the solutions would be to allow modification of rsize&wsize parameters of smb mount. PHP projects usually consist of hundreds of small files (which have to be loaded on every request) and large rsize degrades performance for this use case.

@dimasnake Try beta 21 if you have installer, performance is much better.

@dimasnake
Copy link
Author

@fmasa I don't have the installer. Where I can download 21 beta?

@saschanaz
Copy link

Here is a beta version of Docker for Windows but really beta 21? The latest beta has the version tag 2016-11-10 1.12.3-beta30.

@fmasa
Copy link

fmasa commented Nov 25, 2016

@saschanaz Yes. Take a look at the end of the tag (beta30)

@curlysanders
Copy link

@dimasnake @saschanaz

I found it!
Build 5971 is beta21
https://download.docker.com/win/beta/1.12.0.5971/InstallDocker.msi

Gonna restart my machine and try it.

@curlysanders
Copy link

Can't get it working. Returned to latest beta (30.1).
So frustrating, performance at work on Ubuntu is almost ten times better, while having older hardware.

@fmasa
Copy link

fmasa commented Nov 26, 2016

I read in another issue, that installer auto-updates to latest version. :/ So once you updated, you're stuck with that version.

@dimasnake
Copy link
Author

@fmasa @dopee No difference in beta 21 and 30.

@dgageot dgageot changed the title Incredibly slow (near unusable) on Docker container Shared Volumes Slow Dec 3, 2016
@wclr
Copy link

wclr commented Dec 3, 2016

This issue has is more appropriate name then #188

There is also alike issue in docker for mac: docker/for-mac#77

I also experience this for example with git, when I attach as volume some folder and make git operations on it, with quite large code base speed of operation is significantly slower then on dev machine.

To reproduce it you may just take some image with GIT installed and attach some big repo and try do do git status.

@xdrew
Copy link

xdrew commented Dec 4, 2016

Facing this issue on symfony app developing.
Symfony

@fmasa
Copy link

fmasa commented Dec 5, 2016

@dimasnake Are you sure you have beta 21 installed? I found out that installer auto-updates to latest version no matter what.

@friism Is there any roadmap for this issue?

@dimasnake
Copy link
Author

@fmasa I disable auto-update. I have 1.12.0-beta21 (build: 5971). You have in 21 beta performance better? Show output if this command dd if=/dev/zero of=test.dat bs=1024 count=100000 inside docker container.

@friism
Copy link

friism commented Dec 7, 2016

@fmasa we're aware of the problem. Note that volume I/O performance will likely always be slower than pure in-container performance and pure on-host performance because the host-mounted volume filesystem is mounted over a network.

We're interested in making that overhead as low as possible, of course, but we're not keen on adding a lot of toggles that users have to change depending on what software they happen to be running in containers right now.

@fmasa
Copy link

fmasa commented Dec 8, 2016

@friism Some performance hit in mounted volumes is expected, but it for this particular use case it's just too much for DfW to be usable on daily basis.
I don't see way to optimize smb shares w/o some sort of toggles. Different stacks have different requirements. Why don' you give an option to tweak some parameters in config files if not in GUI? You're cutting not unsignificant part of community out of DfW, because the only viable workaround right now is Docker Machine or some nasty hacks.
I don't want to flame nor hate, just trying to give you some feedback from PHP world :)

@ken9ross
Copy link

/remove-lifecycle stale

@stevekm
Copy link

stevekm commented Jun 16, 2021

I was having similar issues and binding all volumes from with wsl itself instead through the windows mount solved it for me. This is recommended best practice: https://docs.docker.com/docker-for-windows/wsl/#best-practices .

I'm not experiencing any significant performance differences between a real linux machine and docker for windows anymore.

from that link;

Performance is much higher when files are bind-mounted from the Linux filesystem, rather than remoted from the Windows host. Therefore avoid docker run -v /mnt/c/users:/users (where /mnt/c is mounted from Windows).

Instead, from a Linux shell use a command like docker run -v ~/my-project:/sources where ~ is expanded by the Linux shell to $HOME.

This is not a feasible solution. By default, the WSL filesystem is located on the Windows OS install drive, and is limited to 256GB in size. It is common for systems with a lot of high throughput disk IO to have dedicated drives such as fast SSD's meant for this purpose; the solution here makes it impossible to use your dedicated fast storage hardware. If you followed this guide, you will likely lock up your entire OS pretty quickly and fill the boot disk.

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@peter-gribanov
Copy link

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@msxdan
Copy link

msxdan commented Jan 3, 2022

/remove-lifecycle stale

I switched from WSL to Hyper-V as backend because the bind was so slow, after a while working with Hyper-V, today it went for a very good speed to a very low speed, not sure what happened..

This is the comparison of the current speed

Environment

Windows 10
SSD Force MP600
Docker version 20.10.11, build dea9396

Hyper-V Backend

Docker Volume (Using SSD 500 MB/s R/W )

root@e93a61c12105:~# time dd if=/dev/zero of=speedtest bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 0.217735 s, 470 MB/s

real    0m0.220s
user    0m0.040s
sys     0m0.179s

Docker Bind (Using SSD 4 GB/s R/W)

root@78596b019d76:/pwd# time dd if=/dev/zero of=speedtest bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 30.9469 s, 3.3 MB/s

real    0m30.960s
user    0m0.220s
sys     0m4.726s

WSL Backend

Docker Volume (Using SSD 4 GB/s R/W )

root@47c2706508cc:/pwd# time dd if=/dev/zero of=speedtest bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 0.118422 s, 865 MB/s

real    0m0.126s
user    0m0.010s
sys     0m0.116s

Docker Bind (Using SSD 4 GB/s R/W )

root@f4da61498f0c:/pwd# time dd if=/dev/zero of=speedtest bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 14.6283 s, 7.0 MB/s

real    0m14.636s
user    0m0.352s
sys     0m2.240s

@mattodinaturas
Copy link

So.. in 6 years and counting isn't there a solution yet? It's just nuts.. I am working with hyper-v (wsl has too many limitations for my use case) and file access to host directories is painfully slow. The only option is using linux it seems

@freeze000
Copy link

Guys I have the same problem. And I resolved it. I use this guide https://docs.docker.com/desktop/windows/wsl/
(I installed Debian from windows store, I think it's use smaller resources than ubuntu.)

My resultats if I run docker from windows cmd with volume
root@1a72a1c8cef1:/app# dd if=/dev/zero of=test.dat bs=1024 count=100000 100000+0 records in 100000+0 records out 102400000 bytes (102 MB, 98 MiB) copied, 21.049 s, 4.9 MB/s

If i run docker from debian with volume
dd if=/dev/zero of=test.dat bs=1024 count=100000 100000+0 records in 100000+0 records out 102400000 bytes (102 MB, 98 MiB) copied, 0.461592 s, 222 MB/s

And in last case gulp-watch works! I am really happy.

@msxdan
Copy link

msxdan commented Mar 12, 2022

@freeze000

Volumes works fine from windows too

These are my results:

Hyper-V Bakend (Bind)

docker run --rm -it -v C:\Users\PC\Desktop\docker-volume-test:/docker-test ubuntu
root@8b980d71c272:/# cd docker-test/
root@8b980d71c272:/docker-test# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 28.8806 s, 3.5 MB/s

WSL Bakend (Bind)

docker run --rm -it -v C:\Users\PC\Desktop\docker-volume-test:/docker-test ubuntu
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
7c3b88808835: Pull complete
Digest: sha256:8ae9bafbb64f63a50caab98fd3a5e37b3eb837a3e0780b78e5218e63193961f9
Status: Downloaded newer image for ubuntu:latest
root@91d3613ae9c6:/# cd docker-test/
root@91d3613ae9c6:/docker-test# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 11.5315 s, 8.9 MB/s

WSL Bakend (Volume)

docker run --rm -it -v docker-volume-test:/docker-test ubuntu
root@b882a775a77e:/# cd docker-test/
root@b882a775a77e:/docker-test# dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 0.119611 s, 856 MB/s

@freeze000
Copy link

Sorry, not volume I meant bind of course

@dovidweisz
Copy link

dovidweisz commented Mar 14, 2022 via email

@msxdan
Copy link

msxdan commented Mar 14, 2022

@dovidweisz

You may have a volume for multiple reasons, using a Development Container is a good choose for coding but not great for any other stuff, it just copies all inside a volume and creates a container.

Dealing with big files is horrible, we cannot be copying +100 GB to a volume.

I haven't tested in Windows 11 tho, they added some improvements

@drungrin
Copy link

drungrin commented Apr 8, 2022

Share the folder on windows side, mount the shares on the Wsl (ubuntu) distro mount -t cifs -o username=<omitted>,password=<omitted>,file_mode=0777,dir_mode=0777,vers=3.11 //host.docker.internal/Users/<omitted>/my-share /mnt/my-share and then create the volume docker volume create --opt type=none --opt o=bind --opt device=/mnt/my-share my-share and then use the volume.

Speed went from 40-60 MB/s using a CIFS volume to 1 GB/s. Still a lot slower than the mount point, 3GB/s, but enough for me.

speed tested with dd if=/dev/zero of=./testfile bs=1G count=1 oflag=direct inside busybox docker run --rm -it -v my-share:/my-share busybox

Windows 11 and everything on latest version.

@embluk
Copy link

embluk commented Jun 28, 2022

I am still facing the same issues with Windows 11 and Ubuntu wsl. A web app that I am working on will take 15 seconds to load a page, when it usually would be less than 2 seconds. Is there still no solid solution?

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@DeyV
Copy link

DeyV commented Oct 26, 2022

/remove-lifecycle stale
/lifecycle frozen

@embluk
Copy link

embluk commented Oct 26, 2022

Yeah, this is still a major problem.

@dovidweisz
Copy link

dovidweisz commented Oct 27, 2022

At this point it's more likely a problem with WSL2. I ran the test mentioned by OP in WSL2; in my Windows home directory and in my Linux home directory.

username@978TQJ3:/mnt/c/Users/username$ dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 9.48475 s, 10.8 MB/s
username@978TQJ3:/mnt/c/Users/username$ cd
username@978TQJ3:~$ dd if=/dev/zero of=test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB, 98 MiB) copied, 0.10946 s, 936 MB/s

The difference is approximately 100x.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked

@docker docker locked and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests