title: permission denied, mkdir in container on openshift
body: <p>I have a container with nodejs and pm2 as start command and on OpenShift i get this error on startup:</p>
  
  <blockquote>
    <p>Error: EACCES: permission denied, mkdir '/.pm2'</p>
  </blockquote>
  
  <p>I tried same image on a Marathon hoster and it worked fine.</p>
  
  <p>Do i need to change something with UserIds?</p>
  
  <p>The Dockerfile:</p>
  
  <pre><code>FROM node:7.4-alpine
  
  RUN npm install --global yarn pm2
  
  RUN mkdir /src
  
  COPY . /src
  
  WORKDIR /src
  
  RUN yarn install --production
  
  EXPOSE 8100
  
  CMD ["pm2-docker", "start", "--auto-exit", "--env", "production", "process.yml"]
  </code></pre>
  
  <p><strong>Update</strong><br>
  the node image already creates a new user "node" with UID 1000 to not run the image as root.<br>
  I also tried to fix permissions and adding user "node" to root group.<br>
  Further i told pm2 to which dir it should use with ENV var:  </p>
  
  <blockquote>
    <p>PM2_HOME=/home/node/app/.pm2</p>
  </blockquote>
  
  <p>But i still get error: </p>
  
  <pre><code>Error: EACCES: permission denied, mkdir '/home/node/app/.pm2'
  </code></pre>
  
  <p>Updated Dockerfile:</p>
  
  <pre><code>FROM node:7.4-alpine
  
  RUN npm install --global yarn pm2
  
  RUN adduser node root
  COPY . /home/node/app
  WORKDIR /home/node/app
  RUN chmod -R 755 /home/node/app
  RUN chown -R node:node /home/node/app
  
  RUN yarn install --production
  
  EXPOSE 8100
  
  USER 1000
  
  CMD ["pm2-docker", "start", "--auto-exit", "--env", "production", "process.yml"]
  </code></pre>
  
  <p><strong>Update2</strong>
  thanks to Graham Dumpleton i got it working</p>
  
  <pre><code>FROM node:7.4-alpine
  
  RUN npm install --global yarn pm2
  
  RUN adduser node root
  COPY . /home/node/app
  WORKDIR /home/node/app
  
  RUN yarn install --production
  
  RUN chmod -R 775 /home/node/app
  RUN chown -R node:root /home/node/app
  
  EXPOSE 8100
  
  USER 1000
  
  CMD ["pm2-docker", "start", "--auto-exit", "--env", "production", "process.yml"]
  </code></pre>