Dockerfile: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:
Each ''line'' in the Dockerfile generates a new [[Docker_Concepts#Layered_Image|layer]] in the [[Docker_Concepts#Layered_Image|image]]. Multiple commands can be combined on a single line, to reduce the number of layers.
Each ''line'' in the Dockerfile generates a new [[Docker_Concepts#Layered_Image|layer]] in the [[Docker_Concepts#Layered_Image|image]]. Multiple commands can be combined on a single line, to reduce the number of layers.


=Commands=
=Instructions=


==FROM==
==FROM==
Line 38: Line 38:


==ADD==
==ADD==
Copies files from the local filesystem into the image.
<pre>
ADD /something/something_else.conf $MY_PATH
</pre>


==WORKDIR==
==WORKDIR==

Revision as of 14:58, 26 April 2017

Internal

Overview

A Dockerfile defines how a container should look at build time, and it contains all the steps that are required to create the image.

Each line in the Dockerfile generates a new layer in the image. Multiple commands can be combined on a single line, to reduce the number of layers.

Instructions

FROM

Specifies the base image.

FROM node:0.10

USER

The user to run a container's processes as.

Also see Docker Security

ENV

Declares environment variable accessible to the processes in the container:

ENV SOMETHING "something else"

RUN

Running commands like yum in the Dockerfile is discouraged because it increases the time it takes for the build to finish. The alternative is to use base images that already have these updates applied.

ADD

Copies files from the local filesystem into the image.

ADD /something/something_else.conf $MY_PATH

WORKDIR

CMD

MAINTAINER

LABEL

Applies a label to the image.

LABEL "something"="something else" "other label"="some other content"