Quick reference

Dockerfile Cheat Sheet

A practical Dockerfile instruction reference manual, covering core concepts such as inheritance, variables, and initialization to help developers quickly master Docker container building techniques.

· Published · Updated

Scope. Dockerfile instructions for Docker BuildKit. Examples below are separate instruction references, not a complete application. EXPOSE documents a port; publishing it requires an appropriate docker run -p option.

Dockerfile provides the instructions needed to build a container and the commands to be executed when the container runs.

Inheritance

FROM ruby:3.3-slim

Variables

ENV APP_HOME=/myapp
RUN mkdir $APP_HOME

Initialization

RUN bundle install
WORKDIR /myapp

Onbuild

ONBUILD RUN bundle install

Commands

EXPOSE 5900
CMD    ["bundle", "exec", "rails", "server"]

Official reference

Related topics