Use docker-sync to solve the virtual container program docker for mac starts running slow problems

background:

The new recruits OG company has a very large project, in order to avoid repeating new students create the wheel, man has to have all the items needed to lay up a mirror for us to start docker.

Initial start-docker use the following command:

docker run -itd -p 80:80 -v /web/docker:/web/docker  centos

(Ps: docker run and other related -i -p -v meaning no longer go into details here)

When the starting container can be seen, the use of docker comes -v (-volume) mac way of local and paths within the docker container mapping.

 

 

problem:

1. Start container normal, normal environment, but the project is running very slow, others mac build local environmental 1-2 seconds to run a page, the vessel ran directly more than 15-20 seconds.

2. git status within the container project also giant slow more than ten seconds.

Impact of development efficiency is very early in the project direct entrance die ( '111'); soon after the discovery response, the basic rule out nginx - problems with the interaction between php. Google Baidu and passing a pass, to the final position, the file system (osxfs) in the local file system and mac docker container inconsistencies, the need for frequent file format conversion.

 

 

solve:

Docker-sync using a route map in the form of a container mounted. Details can docker-sync google Baidu itself, only recorded use herein.

 

installation:

gem install docker-sync

brew install fswatch

brew install unison

brew install eugenmayer/dockersync/unox

 

(Ps when did your own sudo permissions)

 

use:

cd / web / docker / xxx # project root path

vim docker-sync.yml # docker-sync profiles

It reads as follows:

version: '2'    

syncs:

    xxx-sync: #ps: name generated mount the container, the container typically develop -sync

        sync_strategy: 'unison'

        src: '.'

docker-sync start # start time has generated a container file name xxx-sync, you can docker ps own view.

Next, any local modification, the file may be within the container has self-xxx-sync synchronization.

This time start container

docker run -itd -p 80:80 -v xxx-sync:/web/docker  centos   

The new container file synchronization time-consuming problem has been basically solved.

ps1: When the computer restarts or occasional two-way synchronization problems, go to the root directory of the local project execution once docker-sync start can be.

ps2: the container has run up, if want to solve this problem, you need to run the container under their own Baidu configuration file, change it's path -v parameter.

Guess you like

Origin www.cnblogs.com/camouflage/p/11587163.html