Building images
Dockerfile¶
It all starts with a Dockerfile: a text file that lists the instructions Kleene runs to turn a base image into a new image — which packages to install, which files to copy in, and what the image runs by default. Kleene's getting started guide walks through writing one step by step. Docker's documentation is useful further reading, since Kleene's Dockerfiles follow the same format with some 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.