Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Instruction RUN

Summary

RUN <command> [...<arg>]

The RUN instruction executes the given command inside the build namespace.

# enable the foo service
RUN systemctl enable foo.service

Important

Arguments are executed as-is, i.e. without shell expansion, redirection, piping, etc.

This ensures full control over the parsing of commands, but it also means normal shell syntax is not available:

# BROKEN: This will call "cat" with 3 arguments
RUN cat /etc/hostname "|" md5sum
#   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this will not work

Instead, /bin/sh can be called explicitly:

# This will produce the md5sum of /etc/hostname
RUN /bin/sh -c "cat /etc/hostname | md5sum"