Skip to content

Building images

Dockerfile

It all starts with a Dockerfile. For a thorough walk-through of what a Dockerfile is, it is recommended to consult Docker's documention or Kleene's getting started guide, which is an adapted version of Docker's guide, to highlight differences.

Kleened builds images by reading the instructions from a Dockerfile, using a subset of the instructions known from Docker. You can find Kleene's specification reference in the Dockerfile reference.

Here are the most common and basic instructions:

Instruction Description
FROM <image> Defines a base for your image. This is used to create a new designated filesystem for the image that is being built.
RUN <command> Executes any commands within the designated filesystem. RUN also has a shell form for running commands.
WORKDIR <directory> Sets the working directory for any RUN, CMD, and COPY instructions that follow it in the Dockerfile.
COPY <src> <dest> Copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.
CMD <command> Defines the default command that runs when starting containers based on this image.

The default filename to use for a Dockerfile is Dockerfile, without a file extension. Using the default name allows you to run the klee build command without having to specify additional command flags.

Some projects may need distinct Dockerfiles for specific purposes. A common convention is to name these Dockerfile.<something>. Such Dockerfiles can then be used through the --file (or -f shorthand) option on the klee build command. Refer to the klee build section in the klee reference documentation to learn about build configuration.