Non classifié(e)

Accélérez Docker pour Mac avec Docker-Sync

Author
Speed up Docker for Mac with docker-sync

Step 1. Install docker sync

gem install docker-sync --no-rdoc --no-ri
docker pull eugenmayer/unison:2.51.2.1

Step 2. Create docker-sync.yml in the main directory of your project and include the following config in the file:

version: "2"
syncs:
  app-code-sync:
    # Source directory
    src: './src'
    # This will exclude the files/folders you specify.
    sync_excludes: [
      '.git'
    ]
  sync_host_ip: '127.0.0.1'
  sync_host_port: 10872

Step 3. Create docker-compose-dev.yml in the main directory

Imagine you have docker_compose.yml like this and you want to sync files folder in ./src with docker-sync

version: '3.5'

networks:
  laravel:

services:
  php:
    build:
      context: ./docker/php
    image: 'php:alpine'
    container_name: kutia_php
    ports:
      - '9000:9000'
    volumes:
      - ./src:/src
    networks:
      - laravel

First of all, remove the line – ./src:/src (it causes the container to slow down). Then add the following config to the docker-compose-dev.yml file

version: '3.5'

networks:
  laravel:

services:
  php:
    build:
      context: ./docker/php
    image: 'php:alpine'
    container_name: kutia_php
    ports:
      - '9000:9000'
    volumes:
      - app-code-sync:/src:nocopy
    networks:
      - laravel

volumes:
  app-code-sync:
    external: true

Step 4. Start docker-sync

docker-sync start

If you want to stop, then replace start with stop . To clean up the log and reset docker-sync, use clean .Step 5. Start containers with Docker Compose

docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d

To check if everything is running properly, run docker-compose ps and check for the names of the container with app-code-sync and kutia_php . If they exist, then hooray! Your app is now up and running with docker-sync.

Créons des liens

Contactez-nous

Travaillons ensemble Travaillons ensemble