Docker-sync
本文於461天之前發表,文中內容可能已經過時。如有疑問,請在評論區留言。
起因
因 Docker on MAC 的 IO 會很慢的瓶頸,查資料大致可分為以下幾種解法:
- Disktop Tool 改使用 docker ce edge 版本
- 改用 Docker-machine-parallels
- 推薦使用 docker-sync 改善 IO
docker-sync 測試
安裝 docker-sync
1
2
3
4gem install docker-sync
brew install unison
brew install eugenmayer/dockersync/unox
brew install fswatch編寫同步 yml 檔案
1
2
3
4
5
6version: '2'
syncs:
ProjectName-Sync:
src: '.'
sync_strategy: native_osx
sync_userid: 1000啟動 docker-sync
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47fanka@FankaMBP ~/ProjectName %>docker-sync start
ok Starting native_osx for sync ProjectName-Sync
Unable to find image 'eugenmayer/unison:2.51.2.1' locally
2.51.2.1: Pulling from eugenmayer/unison
1eae7a7426b0: Pull complete
3aa35cd67672: Pull complete
0b90242c76a3: Pull complete
8bf04f18c959: Pull complete
dda7831d2dcd: Pull complete
060e04f93ee5: Pull complete
0a64e8572226: Pull complete
3ca3985a9426: Pull complete
Digest: sha256:636559840565e7c6358d11b6a0ece9241f5ad476dc5c4b61af52be25ce3a3419
Status: Downloaded newer image for eugenmayer/unison:2.51.2.1
doing initial sync with unison
Unison 2.51.2 (ocaml 4.06.1): Contacting server...
Looking for changes
Reconciling changes
Propagating updates
UNISON 2.51.2 (OCAML 4.06.1) started propagating changes at 15:40:17.91 on 07 May 2020
[BGN] Copying ProjectName from /host_sync to /app_sync
Failed: Error in copying locally:
/host_sync/ProjectName/lagvm_p/.DS_Store: No such file or directory
[BGN] Copying .DS_Store from /host_sync to /app_sync
[END] Copying .DS_Store
[BGN] Copying .docker-sync from /host_sync to /app_sync
[END] Copying .docker-sync
[BGN] Copying build_la.sh from /host_sync to /app_sync
[END] Copying build_la.sh
[BGN] Copying build_qnx.sh from /host_sync to /app_sync
[END] Copying build_qnx.sh
[BGN] Copying docker-sync.yml from /host_sync to /app_sync
[END] Copying docker-sync.yml
[BGN] Copying upla.sh from /host_sync to /app_sync
[END] Copying upla.sh
UNISON 2.51.2 (OCAML 4.06.1) finished propagating changes at 16:03:26.37 on 07 May 2020
Saving synchronizer state
Synchronization incomplete at 16:03:26 (6 items transferred, 0 skipped, 1 failed)
failed: ProjectName
real 1h 37m 18s
user 7m 39.82s
sys 7m 16.35s
chown ing file to uid 1000
b9040330be0b548ad7a2a5b02dc9a6e9da38100bd6bd5409b5601fe1109361ef
success Sync container started
success Starting Docker-Sync in the background
fanka@FankaMBP ~/ProjectName %>ls掛載 share volume 到 Container
1
docker run -itd --name=ContainerName -v ProjectName-Sync:/home/UserID/ProjectName DockerImageName:latest bash
確認 掛載目錄是否有資料( 72 is Container ID)
1
2
3fanka@FankaMBP ~ %>docker exec -it 72 ls /home/UserID/ProjectName [16:17:54]
build_1.sh docker-sync.yml run.sh
build_2.sh ProjectName