title: Yarn fails running on Dockerfile
body: <p>I install <code>yarn</code> and then I would like to execute it using the next Dockerfile: </p>
  
  <pre><code>FROM ubuntu:trusty
  ....
  USER node
  RUN npm install -g yarn
  RUN ["/bin/bash", "-c","yarn install"]
  </code></pre>
  
  <p>But it fails with: </p>
  
  <pre><code>/bin/bash: yarn: command not found
  ERROR: Service 'falink-frontend4' failed to build: The command '/bin/bash -c yarn install' returned a non-zero code: 127
  </code></pre>
  
  <p>I just try using the next:</p>
  
  <pre><code>FROM ubuntu:trusty
  ....    
  USER node
  RUN npm install -g yarn
  RUN yarn install
  </code></pre>
  
  <p>But it fails to with:</p>
  
  <pre><code>/bin/sh: 1: yarn: not found
  ERROR: Service 'falink-frontend4' failed to build: The command '/bin/sh -c yarn install' returned a non-zero code: 127
  </code></pre>
  
  <p>Then I connect to the container using <code>docker exec -it XXXXX /bin/bash</code>, I run <code>yarn install</code> and it works fine. When I access inside the docker container I use <code>node</code> user as on the Dockerfile.</p>
  
  <p>This is my entery Dockerfile:</p>
  
  <pre><code>FROM ubuntu:trusty
  
  # Create app directory
  RUN mkdir -p /usr/src/app
  
  
  #use mirrors for faster apt downloads no matter where the machine that builds the image is
  RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted universe multiverse" &gt; /etc/apt/sources.list; \
      echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted universe multiverse" &gt;&gt; /etc/apt/sources.list; \
      echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted universe multiverse" &gt;&gt; /etc/apt/sources.list; \
      echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main restricted universe multiverse" &gt;&gt; /etc/apt/sources.list
  
  #install required software before using nvm/node/npm/bower
  RUN apt-get update &amp;&amp; apt-get install -y libfreetype6 libfontconfig curl git python build-essential
  
  #add user node and use it to install node/npm and run the app
  RUN useradd --home /home/node -m -U -s /bin/bash node
  
  #allow some limited sudo commands for user `node`
  RUN echo 'Defaults !requiretty' &gt;&gt; /etc/sudoers; \
      echo 'node ALL= NOPASSWD: /usr/sbin/dpkg-reconfigure -f noninteractive tzdata, /usr/bin/tee /etc/timezone, /bin/chown -R node\:node /myapp' &gt;&gt; /etc/sudoers;
  
  #run all of the following commands as user node from now on
  USER node
  
  RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
  
  #change it to your required node version
  ENV NODE_VERSION 6.11.0
  
  #needed by nvm install
  ENV NVM_DIR /home/node/.nvm
  
  #install the specified node version and set it as the default one, install the global npm packages
  RUN . ~/.nvm/nvm.sh &amp;&amp; nvm install $NODE_VERSION &amp;&amp; nvm alias default $NODE_VERSION &amp;&amp; npm install -g yarn &amp;&amp; npm install -g phantomjs@1.9.20 koa@2.0.0 koa-static@2.0.0 koa-convert@1.2.0  koa-route koa-connect-history-api-fallback koa-body-parser fs@0.0.2 axios lodash moment
  
  ADD ./Falink_front/run_all.sh /run_all.sh
  
  COPY ./Falink_front/webapp /myapp
  
  ADD ./Falink_front/scrapping.js /code/scrapping.js
  ADD ./Falink_front/package.json /code/package.json
  COPY ./Falink_front/public /code/public
  COPY ./Falink_front/src /code/src
  ADD ./Falink_front/yarn.lock /code/yarn.lock
  
  USER root
  RUN chown -R node:node /code
  
  USER node
  RUN ["/bin/bash", "-c","yarn install"]
  </code></pre>
  
  <p>What could be the problem?</p>