title: AWS Lambda read-only file system error failed to create directory with Docker image
body: <h2>Problem</h2>
  <p><strong>Docker image compiles successfully, however fails when ran from Lambda because of its read only file system.</strong></p>
  <h2>Summary</h2>
  <p><a href="https://github.com/luminati-io/luminati-proxy" rel="nofollow noreferrer">Luminati-proxy</a> has a docker integration for their proxy manager. I copied over their <a href="https://github.com/luminati-io/luminati-proxy/blob/master/Dockerfile" rel="nofollow noreferrer">docker file</a> and appended it to my own docker file for pushing out a script to AWS Lambda. The <strong>building of the docker image was successful</strong>, but when pushed off to Lambda, it <strong>failed because of a read only file system error</strong>:</p>
  <pre><code>Failed to create directory /home/sbx_user1051/proxy_manager: [code=EROFS] Error: EROFS: read-only file system, mkdir '/home/sbx_user1051'
  2022-02-28 19:37:22.049 FILE (8): Failed to create directory /home/sbx_user1051/proxy_manager: [code=EROFS] Error: EROFS: read-only file system, mkdir '/home/sbx_user1051' 
  </code></pre>
  <h2>Analysis</h2>
  <p>Upon examining the trackback, the error is <strong>focused on the proxy_manager installation</strong> and <strong>fails with directory changes</strong> (mkdir, mk_work_dir ...). These changes are made within the .js files of the GitHub which is pulled from the docker file as the proxy_manager installation. Obviously the <strong>only mutable directory on Lambda is the /tmp</strong> directory, but is there a workaround for getting this set up without resorting to putting everything under the /tmp directory as it wipes itself upon runtime? <strong>Reinstalling a proxy_manager each run is not at all ideal</strong>...</p>
  <h2>Answer?</h2>
  <p>Could this be as simple as setting environment stipulations such as:</p>
  <pre><code>ENV PATH=...
  ENV LD_LIBRARY_PATH=...
  </code></pre>
  <p>If so, I how should they be configured? I am adding the docker file below for quick reference:</p>
  <pre><code>FROM node:14.18.1
  RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
      &amp;&amp; sh -c 'echo &quot;deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main&quot; &gt;&gt; /etc/apt/sources.list.d/google.list' \
      &amp;&amp; apt-get update \
      &amp;&amp; apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
        --no-install-recommends \
      &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  USER root
  RUN npm config set user root
  RUN npm install -g npm@8.1.3
  RUN npm install -g @luminati-io/luminati-proxy
  ENV DOCKER 1
  CMD [&quot;luminati&quot;, &quot;--help&quot;]
  </code></pre>
  <p>I appreciate the insight!</p>