Running Webpack-dev-server in docker is significantly slower than on local machine

For those in a similar spot, as Matt suggested, the issues were coming from having a mounted volume. I sped the build up significantly by using docker's volume cache mode. The docs on it are here.

The command looks something like this:

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


I would recommend using delegated instead of cached as per the documentation:

Cached: The host is authoritative in this case. There may be delays before writes on a host are available to the container.

Delegated: The container is authoritative. There may be delays until updates within the container appear on the host.

So the docker-compose file would be as following:

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:delegated

Apart from adding 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

I also recommend you to upgrade docker-for-mac to newest version (bump to version 2.0.0 had significant performance improvement on my mac).

Last recommendation is to raise default CPU/Memory limits in docker-for-mac settings:

docker cpu/memory limits