title: Docker npm run test very slow
body: <p>Learning Docker and playing around with Node apps and I'm seeing some consistently poor behavior, especially when it comes to hot reload (works but takes over 20 seconds the first time) and testing.</p>
  <p>Docker File to create the initial Image</p>
  <pre><code>FROM node:alpine
  
  WORKDIR /app
  
  COPY ./package.json ./
  
  RUN npm install
  
  COPY ./ ./
  
  CMD [&quot;npm&quot;,&quot;run&quot;,&quot;start&quot;]
  </code></pre>
  <p>Docker Compose file</p>
  <pre><code>version: '3.9'
  services:
    frontend:
      image: frontend:v1
      working_dir: /app
      volumes:
        - ./:/app
      ports:
        - 3000:3000
      
  </code></pre>
  <p>App Configuration (defaults, no changes to any of the files):</p>
  <pre><code>npx create-react-app
  </code></pre>
  <p>Testing results from within the container:</p>
  <pre><code> PASS  src/App.test.js (6.284 s)
    ✓ renders learn react link (93 ms)
  
  Test Suites: 1 passed, 1 total
  Tests:       1 passed, 1 total
  Snapshots:   0 total
  Time:        10.926 s, estimated 18 s
  Ran all test suites.
  
  Watch Usage: Press w to show more.
  </code></pre>
  <p>App.test</p>
  <pre><code>import { render, screen } from '@testing-library/react';
  import App from './App';
  
  test('renders learn react link', () =&gt; {
    render(&lt;App /&gt;);
    const linkElement = screen.getByText(/learn react/i);
    expect(linkElement).toBeInTheDocument();
  });
  </code></pre>
  <p>On my local host everything works within expected time frames but when moving over to a docker container things seem to slow down.  I'm curious to know where to look in regards to resources allocated to the docker container?</p>
  <p>FYI whether I run docker compose or docker run directly the test results and the 20 second hot reload time still persist.  I've looked for some settings to fix this but can't seem to find any.  Thanks in advance.</p>
  <p>Also thought that I would add that there is nothing in the logs except for standard React output such as Starting the Dev Server and you can now view your app in the browser with the appropriate links.  Webpack compiled successfully.  With the tests it's the same thing, no errors, standard output just really long test run times within the container which tells me memory or CPU issue but I didn't know where to look for that.  Thanks</p>