By Lukas Aichbauer & Ivan Popovic | February 29, 2024 | 3 min watch
Learn in 162 seconds why you need Docker, what it is all about, and how the three core components work together.
FROM <base-image>
β Set the base image for your Dockerfile (e.g. FROM node:18-alpine
). You can search for them on Docker Hub
COPY <path-on-host-file-system> <path-in-image-file-system>
β Copy files and directories into the final Docker image (e.g. COPY ./package* .
).
RUN <command>
β Run a command inside your Docker image, but on build time (e.g. RUN npm install
)
EXPOSE <port>
β Glorified comment telling a developer which ports are used in this Docker image (e.g. EXPOSE 3000
)
CMD [<command>, <option>, <...>]
β This is the command that will be executed when the container is started (e.g. CMD ["node", "./build/server.js"]
)