OSXã§Webã¢ããªã±ã¼ã·ã§ã³ãéçºããä¸ã§Docker on Macã¯é常ã«ä¾¿å©ã§ã¯ããã®ã ãããã¡ã¤ã«ã·ã¹ãã ã®é¢ä¿ä¸ã å¤æ°ã®ãã¡ã¤ã«ããã¦ã³ããæ¸ãæããé«é »åº¦ã§çºçãããããªç¨éã§ã¯åä½ãé常ã«éããªã£ã¦ãã¾ãã
ï¼åã®å ´åã ã¨æè¿ã¯Webpackã®dev-serverã«ããã©ã¤ããã¼ãã使ã£ãããã³ãã¨ã³ãéçºããã£ã¦ããã ãã©ãããããã¡ã¤ã«æ°ãå¢ããã«ãããã£ã¦æ¿çã«éããªã£ã¦ããã®ã ã»ã»ã»ï¼
ããã§ãã¡ã¤ã«è»¢éã«ãã£ã¦æ¬ä¼¼çã«ãã¦ã³ããã¦ãããã®ãããªåä½ãå®ç¾ãã åä½é度ã®ä½ä¸ãåé¿ãããã¼ã«ãdocker-syncã§ããã
å°å ¥
Ruby製ãããã®ã§gem install
$ sudo gem install docker-sync
å é¨ã§ä½¿ããããã³ãã³ãã諸ã ç¨æ
brew install fswatch brew install rsync brew install unison curl "https://raw.githubusercontent.com/hnsl/unox/master/unox.py" -o "/usr/local/bin/unison-fsmonitor" && chmod +x /usr/local/bin/unison-fsmonitor
è¨å®
docker-composeæ¬ä½
ã²ã¨ã¾ãcentos7ãç«ã¡ä¸ããã ãã®ãã®ãæ³å®
# docker-compose.yml version: "2" services: main: image: centos:7
docker-syncã®è¨å®
# docker-sync.yml version: "2" syncs: sync-volume: # ããªã¥ã¼ã å(ä»»æã®ååãã¤ãã) src: ./mount_dir/ # ãã¹ãå´ã®ãã£ã¬ã¯ããª(ä¸èº«ããåæããããå ´åã¯æå¾ã®/ãå¿ããã«) dest: /container_dir # ã³ã³ããå´ã®ãã¹ sync_host_port: 10871 # åæã«ä½¿ç¨ãããã¹ãå´ã®ãã¼ã(ãã¶ããªããã°ãªãã§ãè¯ã) sync_strategy: rsync # åæææ³(ã²ã¨ã¾ããã¹ãâã³ã³ããã®ä¸æ¹éè¡ã§æ§ããªãã®ã§rsyncã§ãåæ¹åãå¿ è¦ãªãunison)
docker-syncãç¨ããããã®docker-composeã®ä¸æ¸ãè¨å®
# docker-compose.override.yml version: "2" volumes: sync-volume: external: true services: main: volumes: - sync-volume:/container_dir
ãã®ä»
ãã¹ãç¨ã«ãã£ã¬ã¯ããªåã£ã¦ãã¡ã¤ã«ãç¨æ
$ ls ./mount_dir/ test.txt $ cat ./mount_dir/test.txt test
使ãæ¹
èµ·å
ãã¡ã¤ã«åæã®ããã®ã¿ã¹ã¯ãã¹ã¿ã¼ã
$ docker-sync start --daemon
å®éã«docker-composeã§ç¢ºèªããã¨ã»ã»ã»
$ docker-compose run --rm main ls /container_dir test.txt $ docker-compose run --rm main cat /container_dir/test.txt test
ãã¦ã³ãããã¦ãããã¨ã確èªã§ããã
ãã¹ãããã®æ¸ãè¾¼ã¿ã¸ã®è¿½å¾
$ docker-compose run --rm main watch cat /container_dir/test.txt
ã¨ãã£ãä¸ã§å¥çªã§
$ echo hogehoge >> ./mount_dir/test.txt
ã§ã²ã¨ã¾ããã¹ãå´ã®ãã¡ã¤ã«ã«è¿½å¾ãã¦ãããã¨ã¯ç¢ºèªã§ããã
å¾çä»ã
$ docker-sync list $ docker-sync stop $ docker-sync clean
è£è¶³
ã¡ãªã¿ã«ç¶æ³ã«ãã£ã¦ã¯ã³ã³ããå ã«é ç½®ãããã¡ã¤ã«ã®ã¦ã¼ã¶ãåºå®ãããå ´åãããã
sync_strategy: unison
ã§ããã°sync_user_id
ã¨ãã¦ãã¡ã¤ã«ã«ä»å ãããã¦ã¼ã¶IDãæå®ãããã¨ãã§ããã
ã¾ããdocker_sync_stack start
ã³ãã³ãã«ããdocker-composeãåæã«èµ·åããããã¨ãã§ããã
- ä½è : WINGSããã¸ã§ã¯ãé¿ä½å¿ä¿
- åºç社/ã¡ã¼ã«ã¼: ç¿æ³³ç¤¾
- çºå£²æ¥: 2015/11/19
- ã¡ãã£ã¢: Kindleç
- ãã®ååãå«ãããã° (3件) ãè¦ã
追è¨
ä»ãã¦ã³ãã¼ãã§ããææ°ã®Docker for Mac v17.06ã§ã¯ãã¦ã³ãã®é度ã大åæ¹åããã¦ããé°å²æ°ãªã®ã§ãdocker-syncãããä¸è¦ãããããªãã
ãã£ã±ãæåã®è¨å®ãé¢åãªã®ã¨ãæå³ããvolumeãæ®ã£ãããã¦éç¨ã«è½ã¨ãç©´ããã£ãããããã§ã使ããªãã§æ¸ããªãããã«è¶ãããã¨ã¯ãªãã