Docker For Mac Slow Sync
「クソみたいに遅いじゃん。」自分の経験ではないですが、今後の為に資料を調査して理由・対応方法を咲くってみました。
At least for our workflow its much better than the slow bind mound performance of Docker for Mac and the productivity in using docker on mac is now on a usable level for our team. Pikachu volleyball download for mac. Yes, the shown setup has time-drift issues on hybernate because not installing the virtualbox-guest-agent or a ntpd with a auto-sync timer. 运维 使用 docker-sync 让 mac 和 docker 之间的文件同步变快 heroyct 2018年08月06日 最后由 zhaojc 回复于 2019年06月24日 7893 次阅读 最近,在 mac 上面安装了 docker,然后让开发环境运行在 docker 上面.
遅い理由
結論としては「Docker For Mac」がosxfsを採用している。あ!!それよりosxfsがOSXのFSEvents APIとLinux’s inotify APIをマッピングさせているのが原因です。
参考:https://forums.docker.com/t/file-access-in-mounted-volumes-extremely-slow-cpu-bound/8076/158
- osxfsの throughput は250 MB/s-> これはほとんどのAPPで問題にならないはず
- コンテナ内からosxfsに対するファイルIOのシステムコールはlatencyが遅い。書き込み時で200μs-> 通常のファイルシステムであれば under 10μs(クソやられた感じ)
対応方法
じゃ、簡単!!「Docker For Mac」を使えなければ良い。( ゚Д゚)ヴォケ!!
VirtualBoxを利用
docker-machineでVirtualBox上に立ち上げたdocker環境で開発環境を構築する。うん、面倒だ〜〜〜(;^ω^)
Docker For Macを使わない
CE 17.12 (edge) チャンネルを使うこと。(・д・)チッ
参考:https://blog.hanhans.net/2017/05/10/docker-user-guided-caching/
コンテイナ間を爆速で同期する
例としてはdocker-syncをおすすめします。rsyncで設定が簡単かな。
対策の実験
興味がある方はこちらへ
Laravel + Docker + 開発環境
This page contains information on how to diagnose and troubleshoot Docker Desktop issues, send logs and communicate with the Docker Desktop team, use our forums and Success Center, browse and log issues on GitHub, and find workarounds for known problems.
Troubleshoot
Choose > Troubleshootfrom the menu bar to see the troubleshoot options.
The Troubleshoot page contains the following options:
Restart Docker Desktop: Select to restart Docker Desktop.
Run Diagnostics: Select this option to diagnose any issues on Docker Desktop. For detailed information about diagnostics, see Diagnose problems, send feedback, and create GitHub issues.
Reset Kubernetes cluster: Select this option to delete all stacks and Kubernetes resources. For more information, see Kubernetes.
Reset disk image: This option resets all Docker data without areset to factory defaults. Selecting this option results in the loss of existing settings.
Reset to factory defaults: Choose this option to reset all options onDocker Desktop to their initial state, the same as when Docker Desktop was first installed.
Uninstall: Choose this option to remove Docker Desktop from yoursystem.
Uninstall Docker Desktop from the command line
To uninstall Docker Desktop from a terminal, run: <DockerforMacPath>--uninstall
. If your instance is installed in the default location, thiscommand provides a clean uninstall:
You might want to use the command-line uninstall if, for example, you find thatthe app is non-functional, and you cannot uninstall it from the menu.
Diagnose problems, send feedback, and create GitHub issues
In-app diagnostics
If you encounter problems for which you do not find solutions in thisdocumentation, on Docker Desktop issues onGitHub, or the Docker Desktop forum, we can help you troubleshootthe log data.
Choose > Troubleshoot > Run Diagnostics.
Once the diagnostics are available, you can upload them and obtain aDiagnostic ID, which must be provided when communicating with the Dockerteam. For more information on our policy regarding personal data, seehow is personal data handled in DockerDesktop.
If you click Report an issue, this opens Docker Desktop for Mac issues on GitHub in your web browser in a “New issue” template. Add the details before submitting the issue. Do not forget to copy/paste your diagnostic ID.
Diagnosing from the terminal
In some cases, it is useful to run the diagnostics yourself, for instance, ifDocker Desktop cannot start.
First, locate the com.docker.diagnose
tool. If you have installed Docker Desktop in the Applications directory, then it is located at/Applications/Docker.app/Contents/MacOS/com.docker.diagnose
.
To create and upload diagnostics, run:
After the diagnostics have finished, you should have the following output,containing your diagnostics ID:
The diagnostics ID (here BE9AFAAF-F68B-41D0-9D12-84760E6B8740/20190905152051) iscomposed of your user ID (BE9AFAAF-F68B-41D0-9D12-84760E6B8740) and a timestamp(20190905152051). Ensure you provide the full diagnostics ID, and not just the user ID.
To view the contents of the diagnostic file, run:
Check the logs
In addition to using the diagnose and feedback option to submit logs, you canbrowse the logs yourself. The following documentation is about macOS 10.12onwards; for older versions, see olderdocumentation.
In a terminal
To watch the live flow of Docker Desktop logs in the command line, run the following script from your favorite shell.
Alternatively, to collect the last day of logs (1d
) in a file, run:
In the Console app
Macs provide a built-in log viewer, named “Console”, which you can use to checkDocker logs.
The Console lives in /Applications/Utilities
; you can search for it withSpotlight Search.
To read the Docker app log messages, type docker
in the Console window search bar and press Enter. Then select ANY
to expand the drop-down list next to your docker
search entry, and select Process
.
You can use the Console Log Query to search logs, filter the results in variousways, and create reports.
Troubleshooting
Make sure certificates are set up correctly
Docker Desktop ignores certificates listed under insecure registries, and doesnot send client certificates to them. Commands like docker run
that attempt topull from the registry produces error messages on the command line, for example:
As well as on the registry. For example:
For more about using client and server side certificates, see Adding TLScertificates in the Getting Started topic.
Docker Desktop does not start if Mac user account and home folder are renamed after installing the app
See Do I need to reinstall Docker Desktop if I change the name of my macOSaccount?in the FAQs.
Volume mounting requires file sharing for any project directories outside of /Users
If you are using mounted volumes and get runtime errors indicating anapplication file is not found, access to a volume mount is denied, or a servicecannot start, such as when using Docker Compose,you might need to enable file sharing.
Volume mounting requires shared drives for projects that live outside of the/Users
directory. Go to >Preferences > Resources > File sharing and share the drive that contains the Dockerfile and volume.
Incompatible CPU detected
Docker Desktop requires a processor (CPU) that supports virtualization and, morespecifically, the Apple Hypervisorframework.Docker Desktop is only compatible with Mac systems that have a CPU that supports the Hypervisor framework. Most Macs built in 2010 and later support it,as described in the Apple Hypervisor Framework documentation about supported hardware:
Generally, machines with an Intel VT-x feature set that includes Extended PageTables (EPT) and Unrestricted Mode are supported.
To check if your Mac supports the Hypervisor framework, run the following command in a terminal window.
If your Mac supports the Hypervisor Framework, the command printskern.hv_support: 1
.
If not, the command prints kern.hv_support: 0
.
See also, Hypervisor FrameworkReferencein the Apple documentation, and Docker Desktop Mac system requirements.
Workarounds for common problems
If Docker Desktop fails to install or start properly on Mac:
Make sure you quit Docker Desktop before installing a new version of theapplication ( > Quit Docker Desktop). Otherwise, you get an “application in use” error when you try tocopy the new app from the
.dmg
to/Applications
.Restart your Mac to stop / discard any vestige of the daemon running fromthe previously installed version.
Run the uninstall commands from the menu.
If
docker
commands aren’t working properly or as expected, you may need tounset some environment variables, to make sure you are not using the legacyDocker Machine environment in your shell or command window. Unset theDOCKER_HOST
environment variable and related variables.If you use bash, use the following command:
unset ${!DOCKER_*}
For other shells, unset each environment variable individually as describedin Setting up to run Docker Desktop onMac in Docker Desktop on Mac vs. Docker Toolbox.
Network connections fail if the macOS Firewall is set to “Block all incomingconnections”. You can enable the firewall, but
bootpd
must be allowedincoming connections so that the VM can get an IP address.For the
hello-world-nginx
example, Docker Desktop must be running to get tothe web server onhttp://localhost/
. Make sure that the Docker icon isdisplayed on the menu bar, and that you run the Docker commands in a shell that is connected to the Docker Desktop Engine (not Engine from Toolbox).Otherwise, you might start the webserver container but get a “web page notavailable” error when you go tolocalhost
. For more information on distinguishing between the two environments, see Docker Desktop on Mac vs. Docker Toolbox.If you see errors like
Bind for 0.0.0.0:8080 failed: port is alreadyallocated
orlisten tcp:0.0.0.0:8080: bind: address is already in use
:These errors are often caused by some other software on the Mac using thoseports.
Run
lsof -i tcp:8080
to discover the name and pid of the other process anddecide whether to shut the other process down, or to use a different port inyour docker app.
Known issues
IPv6 is not (yet) supported on Docker Desktop.
A workaround is provided that auto-filters out the IPv6 addresses in DNSserver lists and enables successful network access. For example,
2001:4860:4860::8888
would become8.8.8.8
. To learn more, see theseissues on GitHub and Docker Desktop forums:You might encounter errors when using
docker-compose up
with Docker Desktop(ValueError: Extra Data
). We’ve identified this is likely related to dataand/or events being passed all at once rather than one by one, so sometimesthe data comes back as 2+ objects concatenated and causes an error.Force-ejecting the
.dmg
after runningDocker.app
from it can cause thewhale icon to become unresponsive, Docker tasks to show as not responding inthe Activity Monitor, and for some processes to consume a large amount of CPUresources. Reboot and restart Docker to resolve these issues.Docker does not auto-start on login even when it is enabled in > Preferences. This is related to aset of issues with Docker helper, registration, and versioning.
Docker Desktop uses the
HyperKit
hypervisor(https://github.com/docker/hyperkit) in macOS 10.10 Yosemite and higher. Ifyou are developing with tools that have conflicts withHyperKit
, such asIntel Hardware Accelerated Execution Manager(HAXM),the current workaround is not to run them at the same time. You can pauseHyperKit
by quitting Docker Desktop temporarily while you work with HAXM.This allows you to continue work with the other tools and preventHyperKit
from interfering.If you are working with applications like ApacheMaven that expect settings for
DOCKER_HOST
andDOCKER_CERT_PATH
environment variables, specify these to connect to Dockerinstances through Unix sockets. For example:docker-compose
1.7.1 performs DNS unnecessary lookups forlocalunixsocket.local
which can take 5s to timeout on some networks. Ifdocker-compose
commands seem very slow but seem to speed up when the networkis disabled, try appending127.0.0.1 localunixsocket.local
to the file/etc/hosts
. Alternatively you could create a plain-text TCP proxy onlocalhost:1234 using:and then
export DOCKER_HOST=tcp://localhost:1234
.
There are a number of issues with the performance of directories bind-mountedwith
osxfs
. In particular, writes of small blocks, and traversals of largedirectories are currently slow. Additionally, containers that perform largenumbers of directory operations, such as repeated scans of large directorytrees, may suffer from poor performance. Applications that behave in this wayinclude:rake
ember build
- Symfony
- Magento
- Zend Framework
- PHP applications that use Composer to installdependencies in a
vendor
folder
As a work-around for this behavior, you can put vendor or third-party librarydirectories in Docker volumes, perform temporary file system operationsoutside of
osxfs
mounts, and use third-party tools like Unison orrsync
tosynchronize between container directories and bind-mounted directories. We areactively working onosxfs
performance using a number of differenttechniques. To learn more, see the topic on Performance issues, solutions,and roadmap.If your system does not have access to an NTP server, then after a hibernatethe time seen by Docker Desktop may be considerably out of sync with the host.Furthermore, the time may slowly drift out of sync during use. To manuallyreset the time after hibernation, run:
Or, to resolve both issues, you can add the local clock as a low-priority(high stratum) fallback NTP time source for the host. To do this, edit thehost’s
/etc/ntp-restrict.conf
to add:Then restart the NTP service with: