What is the RUN instruction good for in Docker?

Experience Level: Senior
Tags: Docker

Answer

The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.

There are 2 forms:

Shell form:
RUN <command> (the command is run in a shell, which by default is /bin/sh -c on Linux or cmd /S /C on Windows)

Exec form:
RUN ["executable", "param1", "param2"]

The default shell for the shell form can be changed using the SHELL command.

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker instructions
Docker instructions

Are you learning Docker ? Try our test we designed to help you progress faster.

Test yourself