Docker - dockerfile

Card Puncher Data Processing


A Dockerfile specifies instructions on how to create an image.

See Computer Language

A Dockerfile describes the software that is “baked” into an image. It isn’t just ingredients though, it can tell the software what environment to use or what commands to run.


  • A Dockerfile has no extension
from ...

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]

Docker file Syntax / Structure

When developing a dockerfile, some docker instruction will create layers (also known as commit)

  • In Docker 1.10 and higher, only RUN, COPY, and ADD instructions create layers. Other instructions create temporary intermediate images, and no longer directly increase the size of the build.
  • Docker 17.05 and higher add support for multi-stage builds, which allow you to copy only the artifacts you need into the final image. This allows you to include tools and debug information in your intermediate build stages without increasing the size of the final image.


With multi-stage builds, you use multiple FROM statements in your Dockerfile.

If you use Docker 17.05 or higher, you can use multi-stage builds to drastically reduce the size of your final image


Your build stage may contain several layers, ordered from the less frequently changed to the more frequently changed for example:

  • Install tools you need to build your application
  • Install or update library dependencies
  • Generate your application


RUN apt-get update && apt-get install -y \
  bzr \
  cvs \
  git \
  mercurial \

Documentation / Reference

Discover More
Docker Build Context
Docker - Build (an image from a Dockerfile)

The build command creates an image from: a Dockerfile. and a build context : A build context is a list of files sent to the daemon. Example: All files from: a directory if they are not in ignore...
Card Puncher Data Processing
Docker - Command (CMD)

cmd defines a command that should be run inside the container. You can explicitly pass the cmd as argument to the docker cli. Example: the image is ubuntu the entrypoint is the default /bin/sh...
Card Puncher Data Processing
Docker - Commit (Image History)

Create a new image from a container's changes A RUN instruction in a build dockerfile generates commits. containers can then be created from any point in an image’s history, much like source control....
Card Puncher Data Processing
Docker - Dockerfile env

This page talks OS/Shell Environment variable in dockerfile. Docker variable expansion works the same than variable Environment variables are notated The syntax also supports a few of...
Card Puncher Data Processing
Docker - Encoding (Locale)

In docker linux, in order to set your default encoding, you need to set your locale via environment variable in your dockerfile Check/ List the locales If there is no locale, install them ...
Card Puncher Data Processing
Docker - History

The history command permits you to see the commit history of your image The RUN command in a dockerfile creates automatically a commit
Card Puncher Data Processing
Docker - Image

This page is the container image in Docker. OCI is the standardized container format used by Docker Docker stores downloaded images on the Docker host at the Docker Root Dir location where:...
Card Puncher Data Processing
Docker - Port

Port Management in docker. docker port list port mappings or a specific mapping for the container Look up what port is mapped externally to port 5000 inside the container. Redirecting the...
Card Puncher Data Processing
Docker - Windows Container

Windows container type Windows Server Core base OS image for Windows containers Windows...
Card Puncher Data Processing
Docker - docker-compose

Docker Compose is a powerful tool that enables you to launch multiple Docker images in a coordinated fashion. Compose is a tool for defining and running multi-container Docker applications. Compose uses...

Share this page:
Follow us:
Task Runner