title: Cannot start Chromium in AWS Lambda container but works locally
body: <p>I am trying to set up a headless Chromium browser in AWS Lambda using a docker container. My Dockerfile looks like this</p>
  <pre><code># Build stage
  # ------------
  FROM public.ecr.aws/lambda/nodejs:14 AS builder
  
  RUN yum install -y make
  
  # Install dependencies
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=&quot;true&quot;
  WORKDIR /usr/src
  COPY package*.json .
  COPY tsconfig*.json .
  RUN npm ci
  
  # build Typescript
  COPY . /usr/src
  RUN make compile
  
  # Production stage
  # ------------
  FROM public.ecr.aws/lambda/nodejs:14
  
  # Install Chrome
  COPY docker/google-chrome.repo /etc/yum.repos.d/google-chrome.repo
  RUN yum update -y &amp;&amp; yum install google-chrome-stable -y
  
  # /var/task is where Lambda looks for files by default
  COPY package*.json /var/task/
  
  # Install production dependencies only
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=&quot;true&quot;
  RUN npm install --production
  
  # Copy built files from the previous stage
  COPY --from=builder /usr/src/dist /var/task/
  
  CMD [&quot;app.handler&quot;]
  </code></pre>
  <p><code>google-chrome.repo</code></p>
  <pre><code>[google-chrome]
  name=google-chrome - 64-bit
  baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
  enabled=1
  gpgcheck=1
  gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
  </code></pre>
  <p>I use Node.js and <a href="https://www.npmjs.com/package/puppeteer" rel="noreferrer">Puppeteer</a> to control the browser.</p>
  <pre><code>const browser = await puppeteer.launch({
    dumpio: true,
    headless: true,
    executablePath: config.chromeExecutablePath,
    // all possible options and explanations
    // can be found here https://peter.sh/experiments/chromium-command-line-switches/
    args: [
      '--no-sandbox',
      '--headless',
      '--disable-gpu',
      '--disable-dev-shm-usage',
      '--single-process',
      '--user-data-dir=/tmp/user-data',
      '--data-path=/tmp/data-path',
      '--homedir=/tmp',
      '--disk-cache-dir=/tmp/cache-dir',
    ],
  })
  </code></pre>
  <p>It works perfectly fine when running the container locally but once I deploy it and run it in Lambda I get errors like this, and the whole thing just timeouts eventually.</p>
  <pre><code>/usr/bin/google-chrome: line 45: /dev/fd/62: No such file or directory
  /usr/bin/google-chrome: line 46: /dev/fd/62: No such file or directory
  prctl(PR_SET_NO_NEW_PRIVS) failed
  prctl(PR_SET_NO_NEW_PRIVS) failed
  </code></pre>
  <p>Any idea what could be the problem?</p>