LoginSignup
0
2

More than 3 years have passed since last update.

[メモ]Docker for mac 高速に by docker-sync

Posted at

Railsの開発環境をdocker-composeで動かしていたが、めちゃくちゃ遅いなと思いながら2ヶ月そのまま過ごしていた僕に、光が差し込んだ。

docker-syncをつかう。

準備

gem install docker-sync
brew install fswatch
brew install unison

インストールしたらdocker-syncの設定

docker-sync.yml
version: '2'

syncs:
  sync-volume:
    src: '.'
docker-compose.yml
version: '3'

services:
  app:
    build: .
    tty: true
    stdin_open: true
    volumes:
      - sync-volume:/sample-app:cached # キャッシュオプションもつけとくと早くなる
      - bundle:/bundle
    environment:
      TZ: 'Asia/Tokyo'

volumes:
  sync-volume:
    external: true

いざ、立ち上げ。

docker-sync start  # 先にrsyncをスタート
docker-compose up -d

rsync取り入れ前後でのファイル生成速度の比較

100MBのテストデータを作成。

% docker-compose exec app bash

# time dd if=/dev/zero of=speedtest bs=1024 count=102400
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 62.1419 s, 1.7 MB/s

real    1m2.107s  62秒(病)も時間かかってる。
user    0m0.425s
sys     0m5.966s

syncを起動させた後

% docker-compose exec app bash

# time dd if=/dev/zero of=speedtest bs=1024 count=102400
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 2.50668 s, 41.8 MB/s

real    0m2.613s 2秒に短縮
user    0m0.114s
sys     0m1.164s

しぬほど早い。。
ページ遷移もフォーム送信もめちゃくちゃ早くなってました。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2