Home › Docker Tutorial › Dockerfile
Dockerfile
Describe how to build your own image.
A Dockerfile is a text file of instructions. FROM picks the base image, WORKDIR sets the working folder, COPY adds files, RUN runs a command while building, EXPOSE documents a port and CMD is what runs when the container starts. Build it with docker build -t myapp . (the dot is the build folder).
Example code
FROM node:22-alpine
WORKDIR /app
COPY package.json ./
RUN npm install --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]