Docker build

From NovaOrdis Knowledge Base
Revision as of 23:44, 4 December 2017 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

External

Internal

Overview

Takes a Dockerfile and produces a Docker image. The default location for the Dockerfile is the current directory: the local directory must contain the Dockerfile and whatever else is required to go into the image.

docker build --rm=true -t <tag> <path>|<url> .
docker build --rm=true -t novaordistest/run-loop . 
docker build .

The image goes into the local repository and it is declared as belonging to the <path>|<url> repository:

docker images

REPOSITORY                    TAG        IMAGE ID        CREATED          SIZE
novaordistest/run-loop        latest     c22308970610    5 minutes ago    1.13 MB

Run Example

docker build --rm=true -t novaordistest/run-loop .
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM busybox
 ---> 6ad733544a63
Step 2 : MAINTAINER "Nova Ordis"
 ---> Running in 2ad218dd5e9c
 ---> fbb4cbd9d20e
Removing intermediate container 2ad218dd5e9c
Step 3 : LABEL version "1.0" description "A project that creates a custom Docker image based on a BusyBox base image"
 ---> Running in 2aede00292df
 ---> 9814c9c79887
Removing intermediate container 2aede00292df
Step 4 : ENV NAME "NovaOrdis OpenShift Test Environment" TARGET_DIR "/var/novaordis"
 ---> Running in bb2f8bfa843b
 ---> 40ae6388dd16
Removing intermediate container bb2f8bfa843b
Step 5 : USER root
 ---> Running in 9330a43e9708
 ---> 76ee4eb93f1e
Removing intermediate container 9330a43e9708
Step 6 : COPY run-loop.sh /usr/local/bin/run-loop.sh
 ---> fbf1c0aa45fb
Removing intermediate container 1d2f83c52c79
Step 7 : RUN chmod 755 /usr/local/bin/run-loop.sh
 ---> Running in 9e6a5106ee63
 ---> 2eb53c96e926
Removing intermediate container 9e6a5106ee63
Step 8 : CMD mkdir $TARGET_DIR
 ---> Running in 93cde8761daf
 ---> 60794f39337b
Removing intermediate container 93cde8761daf
Step 9 : VOLUME $TARGET_DIR
 ---> Running in 68b120de3d61
 ---> 3d8a13cc56cf
Removing intermediate container 68b120de3d61
Step 10 : CMD /usr/local/bin/run-loop.sh $NAME
 ---> Running in dfd928793665
 ---> c22308970610
Removing intermediate container dfd928793665
Successfully built c22308970610

Options

--rm

--rm=true

Remove intermediate containers after a successful build (default true).

-t, --tag

Name and optionally a tag in the 'name:tag' format (default []).