title: Docker - Build image from a Dockerfile in a child folder
body: <p>I'm running into a problem with docker that I can't fix by looking at other references, documentation, etc. and since i'm a beginner with Docker I try my luck here. I'm working in a Next.js project that is using Docker to build the app. I'm using the example <a href="https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile" rel="nofollow noreferrer">documentation</a> of Next.js, and <strong>that</strong> works if I have my Dockerfile in the root of my project. However, I want to put it in a folder called <code>etc</code> and use it from there. This is giving me problems, because docker can't find the files that i'm trying to copy to the working directory, see error below.</p>
  <p><strong>Structure</strong></p>
  <pre><code>.
  ├── etc
  │   └── Dockerfile
  ├── package.json
  └── yarn.lock
  </code></pre>
  <p><strong>Command</strong></p>
  <p><code>docker build etc/</code></p>
  <p><strong>Error</strong></p>
  <p><code>failed to compute cache key: &quot;/yarn.lock&quot; not found: not found</code></p>
  <p><strong>Dockerfile</strong></p>
  <pre><code>FROM node:16-alpine AS deps
  # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
  RUN apk add --no-cache libc6-compat
  WORKDIR /app
  COPY package.json yarn.lock ./
  RUN yarn install --frozen-lockfile
  </code></pre>
  <p>I've tried a bunch of things, such as changing the files and paths. Also, in the <a href="https://docs.docker.com/engine/reference/builder" rel="nofollow noreferrer">documentation</a> they mention the <code>-f</code> flag, but that doesn't work for me either because I get the error <code>&quot;docker build&quot; requires exactly 1 argument.</code> when running <code>docker build -f etc/Dockerfile</code>. Is that outdated? Anyway, my question is how to build my app with docker when my dockerfile is not in the root of the project but in a child folder like <code>etc/</code>.</p>