Docker mac symfony 3 is very slow

I am starting a new project with Symfony 3 and I want to use Docker for the development environment. We will be working on this project with a dozen developers, so I want to have a simple installation process.

Here is my docker-compose.yml

version: '2'
services:
db:
    image: mysql
    ports:
        - "3307:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: mydb
        MYSQL_USER: root
        MYSQL_PASSWORD: root
php:
    build: ./php-fpm
    expose:
        - "9001"
    volumes:
        - .:/var/www/project
        - ./var/logs:/var/www/project/app/logs
    links:
        - db
nginx:
    build: ./nginx
    ports:
        - "8001:80"
    links:
        - php
    volumes_from:
        - php
    volumes:
        -  ./var/logs/nginx/:/var/log/nginx

I installed the latest Docker app for Mac (beta). The big problem is that my symfony application is very slow (a simple page takes more than 5 seconds). The same application with MAMP is much faster (maximum 500 ms). Is this a docker problem? How can I debug it?

+4
source share
6 answers

. Docker for Mac linux VM osxfs, . , , , .

+5

, ce edge, .

  • Docker-Edge ( , )
  • docker-compose.yml

Blockquote

php:
    volumes:
        - ${SYMFONY_APP_PATH}:/var/www/symfony:cached

${SYMFONY_APP_PATH} .

+3

docker . Docker, :

MAC OSX:

Docker Toolbox

Install normaly the dmg file.

Open your terminal and type:

`$ docker-machine create --driver virtualbox default `

`$ docker-machine env default`

`eval "$(docker-machine env default)"`

Now you have the docker-machine up and running, any docker-compose, docker command will run "inside the machine".

In our case "Symfony" is a large application. The docker-machine file system is under osxfs, so the application will be very slow.

docker-machine-nfs

:

curl -s https://raw.githubusercontent.com/adlogix/docker-machine-nfs/master/docker-machine-nfs.sh | sudo tee /usr/local/bin/docker-machine-nfs > /dev/null && \ sudo chmod +x /usr/local/bin/docker-machine-nfs

root

$ docker-machine-nfs default

- nfs.

.

-

192.168.99.100:9000

:

$ vboxmanage modifyvm default --natpf1 "default-map,tcp,,9000,,9000'

localhost: 9000

+2

. python script , . , , - "" docker-toolbox.

,

0

, docker OSX, , .

, .

0

https://forums.docker.com/t/file-access-in-mounted-volumes-extremely-slow-cpu-bound/8076.

https://www.docker.com/products/docker-toolbox, https://www.docker.com/docker-mac.

Docker Mac VirtualBox, HyperKit, macOS, Hypervisor.framework macOS 10.10 Yosemite . https://docs.docker.com/docker-for-mac/docker-toolbox/#the-docker-for-mac-environment

I created a workaround that can help you. I am using http://docker-sync.io/ for my symfony project. Before using the page, the dock sync loaded for 30 seconds, now it is below 1 second - https://github.com/Arkowsky/docker_symfony

0
source

All Articles