Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to figure out, what slows down docker?

My problem is the following - I have Docker on OSX with containers containing Redis, NginX, PHP 7 and Unison. Mapped to php-container I have volume with Symfony 3.1.7.

Everything works, but Symfony's "Welcome" page taked ~1.5 second loading time on average. At the same time same setup without docker gives me 0.2 second loading time. Same difference I got for Symfony's console commands, so, I guess, it's not the problem with NginX, and Unison should've negated all issues related to Docker files sync on OSX problem.

Right now I've ran out of ideas what can I do to speed things up and how to figure out what creates that 1.5s delay.

I have same issue on my second MBP, but such thing does not happen on colleagues laptop, which is similar to the one I have, but we were unable to find any difference between two setups.

Everything is running on my MBP with 2.5 GHz i5, 8 Gb RAM and SSD.

Docker 1.12.3, OSX 10.12.1 (Sierra)

docker-compose.yml:

mydockerbox-redis:
  image: phpdockerio/redis:latest
  container_name: mydockerbox-redis

mydockerbox-webserver:
  image: phpdockerio/nginx:latest
  container_name: mydockerbox-webserver
  volumes:
      - ..:/var/www/mydockerbox
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "80:80"
  links:
   - mydockerbox-php-fpm

unison:  
  image: leighmcculloch/unison:latest  
  environment:  
    - UNISON_WORKING_DIR=/unison  
  volumes:
    - ../mydockerbox:/var/www/mydockerbox
  ports:  
    - "5000:5000"

mydockerbox-php-fpm:
  build: .
  dockerfile: php-fpm/Dockerfile
  container_name: mydockerbox-php-fpm
  volumes_from:  
    - unison  
  volumes:
    - ./php-fpm/php-ini-overrides.ini:/etc/php/7.0/fpm/conf.d/99-overrides.ini
  links:
    - mydockerbox-redis

UPD And here is Dockerfile for php-fpm container:

FROM phpdockerio/php7-fpm:latest

# Install selected extensions and other stuff
RUN apt-get update \
    && apt-get -y --no-install-recommends install  php7.0-mongodb php7.0-redis php7.0-igbinary \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*


WORKDIR "/var/www/mydockerbox"
like image 220
Sergii Nester Avatar asked Nov 27 '16 19:11

Sergii Nester


People also ask

Why is my docker container so slow?

When you experience slow Docker performance, check your CPU, memory usage, and available disk space. Consider upgrading your system if a component does not perform as expected. When dealing with a specific container that is performing worse than expected, it may be helpful to check container-specific metrics.

Is 16gb RAM enough for docker?

In addition, when using Docker CE on Windows, configure Docker to use Linux containers. Using Microsoft Windows Containers is not supported as it provides Windows API support to Windows container service instances. Minimum: 8 GB; Recommended: 16 GB.

How can I make docker container faster?

To optimize Docker performance, install Docker directly on a bare-metal server—or consider using a system container hypervisor, such as LXD or OpenVZ, and running Docker inside that. System containers give you an abstraction layer between the guest environment and the host without compromising bare-metal performance.


1 Answers

I suggest you to use the docker-machine-driver-xhyve:

docker-machine/libmachine driver plugin for xhyve/hyperkit (native macOS hypervisor.framework)

You can simply install with brew (I hope you have already installed docker&Co with brew also, otherwise unlink and install them with brew!):

brew install docker-machine-driver-xhyve
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

Then you can create a docker machine as:

docker-machine create --driver xhyve --xhyve-experimental-nfs-share my-xhyve-docker-machine

and use it for run your container

like image 189
Matteo Avatar answered Nov 14 '22 23:11

Matteo