27
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Organization

docker-sync

description

  • docker for mac では volume同期が遅い
  • docker-sync を用いて, 高速化する

prepare docker-sync

console
gem install docker-sync
brew install eugenmayer/dockersync/unox
brew install fswatch unison rsync

prepare docker files

  • 以下 Files を作成
    • Dockerfile
    • docker-compose.yml
    • docker-compose-dev.yml
    • docker-sync.yml

Dockerfile

Dockerfile
FROM centos:7.5.1804

WORKDIR /opt/django/

docker-compose.yml

docker-compose.yml
version: '2'

services:
  django:
    build:
      context: ./
      dockerfile: ./Dockerfile
    working_dir: /opt/django/
    tty: true

docker-compose-dev.yml

docker-compose-dev.yml
version: '2'


volumes:
  django_syncs:
    external: true

services:
  django:
    volumes:
      - django_syncs:/opt/django/:nocopy

docker-sync.yml

docker-sync.yml
version: '2'


options:
  compose-dev-file-path: 'docker-compose-dev.yml'

syncs:
  django_syncs:
    src: './'
    sync_strategy: 'unison'

start sync

console
docker-compose pull
docker-compose build --no-cache
# start sync and docker
#     docker-compose-dev.ymlにて, 設定を上書きしている
docker-sync start
docker-compose -f ./docker-compose.yml -f ./docker-compose-dev.yml up -d

# open console
docker-compose exec django /bin/bash

# stop
docker-sync stop
docker-compose down
# 以下では sync + up を一括で実行する
# 停止は ctrl + c
docker-sync-stack start

以上で同期が高速化する.

参考

https://qiita.com/pocari/items/0340049742927f3a94b7
https://github.com/EugenMayer/docker-sync/wiki
https://github.com/EugenMayer/docker-sync/wiki/8.-Strategies

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
27
Help us understand the problem. What are the problem?