Skip to content
Menu
All videos
Watch & learn

Learn how to create a Dockerfile in 203 seconds

February 29, 20243 min watchEnglish

Description

Learn in 162 seconds why you need Docker, what it is all about, and how the three core components work together.

Learning outcomes

  • What is a Dockerfile?
  • How do I create my first Dockerfile?
  • What Commands do I need?
  • How do the commands work together?
  • How does the cache function work?
  • How do layers work?

Commands You Will Learn

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"])