Dockerfile Instructions

13 cards

Review this deck
All cards in this deck

`FROM node:24-alpine`

base image (the first instruction; only `ARG` may precede it)

`ARG VERSION=1.0`

build-time variable; an `ARG` before FROM is usable only in the FROM line and must be redeclared after FROM to use inside the stage

`ENV NODE_ENV=production`

runtime environment variable

`WORKDIR /app`

set the working directory (created if missing)

`COPY src/ /app/src/`

copy files/dirs from the build context

`ADD archive.tar.gz /app/`

copy + extract (use COPY when you don't need this)

`RUN apt-get update && apt-get install -y curl`

run a command at build time

`EXPOSE 3000`

document a port (doesn't actually open it)

`USER node`

switch user

`VOLUME ["/data"]`

declare a mount point

`LABEL key=value`

metadata

`CMD ["node", "server.js"]`

default command when the container starts

`ENTRYPOINT ["python"]`

fixed command; `docker run` args are only appended (replacing CMD); to override it you must use the `--entrypoint` flag

Dockerfile Instructions – Flashcards – Docker | Học Dev