title: Problems with yarn in docker-compose
body: <p>I have a Docker Compose environment that has been working very differently.</p>
  <p>Here is the setup:</p>
  <h3><code>docker-compose.prod.yaml</code></h3>
  <pre class="lang-yaml prettyprint-override"><code> front_end:
      image: front-end-build
      build:
        context: ./front_end
        dockerfile: front_end.build.dockerfile
  
    nginx:
      build:
        context: ./front_end
        dockerfile: front_end.prod.dockerfile
      ports:
        - 80:80
        - 5000:5000
      environment:
        - CHOKIDAR_USEPOLLING=true
      stdin_open: true
      tty: true
      depends_on:
        - front_end
  
  </code></pre>
  <h3><code>front_end.build.dockerfile</code></h3>
  <pre><code>FROM node:13.12.0-alpine
  COPY package.json ./
  WORKDIR /srv
  RUN yarn install
  RUN yarn global add react-scripts
  COPY . /srv
  RUN yarn build
  </code></pre>
  <h3><code>front_end.prod.dockerfile</code></h3>
  <pre><code>FROM nginx
  EXPOSE 80
  COPY --from=front-end-build /app/build /usr/share/nginx/html
  COPY nginx.conf /etc/nginx/conf.d
  </code></pre>
  <h3>command:</h3>
  <pre><code>docker-compose down &amp;&amp; docker-compose -f docker-compose.prod.yml up --build --remove-orphans nginx
  </code></pre>
  <p>It doesn't work, for various reasons on various runs.</p>
  <p>After various errors, I'm starting with a <code>docker system prune</code>, which at least &quot;resets&quot; the problems to some starting state.</p>
  <p>Various problems include:</p>
  <ul>
  <li><code>yarn install</code> says <code>info There appears to be trouble with your network connection. Retrying...</code> but then proceeds to continue, spitting out various deprecation/incompatibility warnings, and finally getting to &quot;Done&quot;.
  <ul>
  <li>Following this, it usually takes maybe 60+ seconds to even show &quot;Removing intermediate container&quot; and move on to the next step in the dockerfile.</li>
  </ul>
  </li>
  <li>Sometimes the network error will be all I get, and then yarn install will fail which halts the whole process.</li>
  <li><code>yarn install</code> might not show that network error, but show its various warnings between &quot;Resolving packages&quot; and &quot;Fetching packages&quot;, which doesn't seem to make sense although this might be normal.</li>
  <li><code>yarn install</code> might, at any point in this process (including after  install is done, during install, or even during <code>yarn build</code>), report that we're out of space: <code>error An unexpected error occurred: &quot;ENOSPC: no space left on device, mkdir '/node_modules/fast-glob/package/out/providers/filters'&quot;.</code> or something similar.</li>
  </ul>
  <p>The farthest we might get is, in <code>yarn build</code>:</p>
  <pre><code>There might be a problem with the project dependency tree.
  It is likely not a bug in Create React App, but something you need to fix locally.
  
  The react-scripts package provided by Create React App requires a dependency:
  
    &quot;webpack-dev-server&quot;: &quot;3.11.0&quot;
  
  Don't try to install it manually: your package manager does it automatically.
  However, a different version of webpack-dev-server was detected higher up in the tree:
  
    /node_modules/webpack-dev-server (version: 3.10.3) 
  
  Manually installing incompatible versions is known to cause hard-to-debug issues.
  
  If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
  That will permanently disable this message but you might encounter other issues.
  
  To fix the dependency tree, try following the steps below in the exact order:
  
    1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
    2. Delete node_modules in your project folder.
    3. Remove &quot;webpack-dev-server&quot; from dependencies and/or devDependencies in the package.json file in your project folder.
    4. Run npm install or yarn, depending on the package manager you use.
  
  In most cases, this should be enough to fix the problem.
  If this has not helped, there are a few other things you can try:
  
    5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
       This may help because npm has known issues with package hoisting which may get resolved in future versions.
  
    6. Check if /node_modules/webpack-dev-server is outside your project directory.
       For example, you might have accidentally installed something in your home folder.
  
    7. Try running npm ls webpack-dev-server in your project folder.
       This will tell you which other package (apart from the expected react-scripts) installed webpack-dev-server.
  
  If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
  That would permanently disable this preflight check in case you want to proceed anyway.
  
  P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
  
  error Command failed with exit code 1.
  </code></pre>
  <p><code>webpack-dev-server</code> does not actually appear anywhere in my package.json file so there's nothing for me to change there, but otherwise I've tried those 4 steps. And then the next time I run I get the &quot;no space left&quot; error.</p>
  <p>I'll also say, almost separately from this, that there have been times when, for some reason, it will go through all the steps, except with no output whatsover for <code>yarn build</code>, not even &quot;Using cache&quot;. And this, of course, will have the nginx container fail as it tries to get the build files. Or something like that, honestly it's been a while. <strong>But</strong> what does happen when we move on to nginx, is that it will say &quot;Building nginx&quot; for an absurd amount of time, several minutes, before it even gets to the first step in the nginx dockerfile.</p>
  <p>But the problem with the front end build is so big that that nginx thing is basically a separate issue.</p>
  <p>Has anyone experienced (and solved!) anything similar to what I'm experiencing?</p>