Running webpack-dev server in docker is much slower than running on local machine

I move most of my development processes to docker to provide a parallel development environment between computers, so there are no odd errors or problems due to incorrect version matching, etc.

All this goes fine, except that when starting the webpack-dev server inside the docker, the build process is much slower than when I run it only locally on my computer. (Like 3-5 minutes in docker versus 30 seconds to 1 minute in place). Is there any way to speed this up? Is this just a problem with docker / webpack interacting with a large number of files on my hard drive through an installed volume?

If that matters, my host system is a Mac running at high speed on an i7 with 16bg of memory.

I run docker for mac, docker -v returns: Docker version 17.12.0-ce, build c97c6d6

Hope all this is clear enough, let me know if I can add any information!

+6
source share
2 answers

For those in a similar place, Matt suggested, the problems were with the connected volume. I significantly accelerated the build using the Docker volume caching mode. Documents for this are here.

The command looks something like this:

docker run -v \local\director:docker\directory:cached dockerImage

+6
source

Besides adding a cached volume flag to your docker-compose.yaml file:

version: '3'
services:
  front:
    container_name: my-front-dev
    image: my-front-dev-image
    build:
      context: .
      dockerfile: front/Dockerfile.dev
    ports:
      - 5002:80
    volumes:
      - ./front/:/app/:rw,cached

Docker--Mac ( 2.0.0 Mac).

, / Docker--Mac:

docker cpu / memory limits

0

Source: https://habr.com/ru/post/1694328/


All Articles