Docker 容器中的网络性能缓慢

Slow network performance in Docker container

我是 运行 docker/docker 机器上的 OSX Yosemite 和 VirtualBox,我正在尝试连接到一个lein ring server 运行 在主机的容器中加载速度很慢加载时间超过 1 分钟以下是我的配置

Docker 1.12.0 Docker 机器 0.8.0 VirtualBox 5.0.24

我的Docker机器

"ConfigVersion": 3, "Driver": { "IPAddress": "192.168.99.100", "MachineName": "default", "SSHUser": "docker", "SSHPort": 49478, "SSHKeyPath": "/Volumes/NASMAC/VMs/.docker/machine/machines/default/id_rsa", "StorePath": "/Volumes/NASMAC/VMs/.docker/machine", "SwarmMaster": false, "SwarmHost": "tcp://0.0.0.0:3376", "SwarmDiscovery": "", "VBoxManager": {}, "HostInterfaces": {}, "CPU": 1, "Memory": 1024, "DiskSize": 20000, "NatNicType": "82540EM", "Boot2DockerURL": "", "Boot2DockerImportVM": "", "HostDNSResolver": false, "HostOnlyCIDR": "192.168.99.1/24", "HostOnlyNicType": "82540EM", "HostOnlyPromiscMode": "deny", "UIType": "headless", "NoShare": false, "DNSProxy": true, "NoVTXCheck": false }, "DriverName": "virtualbox", "HostOptions": { "Driver": "", "Memory": 0, "Disk": 0, "EngineOptions": { "ArbitraryFlags": [], "Dns": null, "GraphDir": "", "Env": [], "Ipv6": false, "InsecureRegistry": [], "Labels": [], "LogLevel": "", "StorageDriver": "", "SelinuxEnabled": false, "TlsVerify": true, "RegistryMirror": [], "InstallURL": "https://get.docker.com" }, "SwarmOptions": { "IsSwarm": false, "Address": "", "Discovery": "", "Agent": false, "Master": false, "Host": "tcp://0.0.0.0:3376", "Image": "swarm:latest", "Strategy": "spread", "Heartbeat": 0, "Overcommit": 0, "ArbitraryFlags": [], "ArbitraryJoinFlags": [], "Env": null, "IsExperimental": false }, "AuthOptions": { "CertDir": "/Volumes/NASMAC/VMs/.docker/machine/certs", "CaCertPath": "/Volumes/NASMAC/VMs/.docker/machine/certs/ca.pem", "CaPrivateKeyPath": "/Volumes/NASMAC/VMs/.docker/machine/certs/ca-key.pem", "CaCertRemotePath": "", "ServerCertPath": "/Volumes/NASMAC/VMs/.docker/machine/machines/default/server.pem", "ServerKeyPath": "/Volumes/NASMAC/VMs/.docker/machine/machines/default/server-key.pem", "ClientKeyPath": "/Volumes/NASMAC/VMs/.docker/machine/certs/key.pem", "ServerCertRemotePath": "", "ServerKeyRemotePath": "", "ClientCertPath": "/Volumes/NASMAC/VMs/.docker/machine/certs/cert.pem", "ServerCertSANs": [], "StorePath": "/Volumes/NASMAC/VMs/.docker/machine/machines/default" } }, "Name": "default" }

我的docker图片

{ "Id": "819132073e36a026222ad0da90899a0daf1e735ce0f8623202740b355556c136", "Created": "2016-08-28T23:35:03.957961657Z", "Path": "/bin/bash", "Args": [ "lein", "with-profile", "dev", "do", "start-dev" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 3586, "ExitCode": 0, "Error": "", "StartedAt": "2016-08-28T23:35:04.365339872Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:618b57a0e5d07030a3f869607928f5e167b53a6f250f76f88325799888dcac94", "ResolvConfPath": "/var/lib/docker/containers/819132073e36a026222ad0da90899a0daf1e735ce0f8623202740b355556c136/resolv.conf", "HostnamePath": "/var/lib/docker/containers/819132073e36a026222ad0da90899a0daf1e735ce0f8623202740b355556c136/hostname", "HostsPath": "/var/lib/docker/containers/819132073e36a026222ad0da90899a0daf1e735ce0f8623202740b355556c136/hosts", "LogPath": "/var/lib/docker/containers/819132073e36a026222ad0da90899a0daf1e735ce0f8623202740b355556c136/819132073e36a026222ad0da90899a0daf1e735ce0f8623202740b355556c136-json.log", "Name": "/lonely_ritchie", "RestartCount": 0, "Driver": "aufs", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": [ "/Users/kendallarneaud/Documents/Git/ngc-race-along.docker:/data" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": { "3000/tcp": [ { "HostIp": "", "HostPort": "" } ], "9000/tcp": [ { "HostIp": "", "HostPort": "" } ] }, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": true, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": -1, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0 }, "GraphDriver": { "Name": "aufs", "Data": null }, "Mounts": [ { "Source": "/Users/kendallarneaud/Documents/Git/ngc-race-along.docker", "Destination": "/data", "Mode": "", "RW": true, "Propagation": "rprivate" } ], "Config": { "Hostname": "819132073e36", "Domainname": "", "User": "", "AttachStdin": true, "AttachStdout": true, "AttachStderr": true, "ExposedPorts": { "3000/tcp": {}, "9000/tcp": {} }, "Tty": true, "OpenStdin": true, "StdinOnce": true, "Env": [ "no_proxy=*.local, 169.254/16", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "HOME=/root", "JAVA_HOME=/usr/lib/jvm/java-7-oracle", "LEIN_ROOT=true", "LANG=C.UTF-8", "PYTHON_VERSION=2.7.9" ], "Cmd": [ "/bin/bash", "lein", "with-profile", "dev", "do", "start-dev" ], "Image": "rand/docker-clojurescript:latest", "Volumes": null, "WorkingDir": "/data", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "8b5479b9b22a6d653509c99f9b291593ca7664339666cf40bee55044f3c1d778", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "3000/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "32773" } ], "9000/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "32772" } ] }, "SandboxKey": "/var/run/docker/netns/8b5479b9b22a", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "d4164a411f5ca1992eb724c4cd5cb2f013a1eb909b6d3e5f395d07df84ff34f2", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "fb82d366a9a2ad010bda7cdf4e6cb33f083a678756cfdfed01f90d3d2c317dfa", "EndpointID": "d4164a411f5ca1992eb724c4cd5cb2f013a1eb909b6d3e5f395d07df84ff34f2", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02" } } } }

我不确定要提交哪些其他信息来调试这种情况。有什么可以提高性能的吗?

众所周知,在 VirtualBox 中挂载主 (mac) 文件夹的数据传输速度极慢。尝试使用 Docker 代替 Mac,或将您的内容复制到命名卷。例如:

docker create volume --name myvol
docker run --rm --name data-container -v myvol:/data alpine top
docker cp dir/with/files data-container:/data
docker rm -f data-container

这为您提供了一个卷 myvol,您可以将其装载到任何容器上。卷数据保存在 VirtualBox 主机中。

要加快速度,您还可以使用 http://docker-sync.io - 它是在 OSX 下专门为这种情况构建的。