Docker - dockerfile

Card Puncher Data Processing

About

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.

Example

  • 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.

Multi-stage

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

Structure

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

Tools

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

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 - 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 where: sha256:e90fc3a is the , the machine readable version of the image (unique) (default to...
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...
Card Puncher Data Processing
DockerFile - USER

The USER instruction in a Dockerfile will set the user and the group running the next instructions. It determines the user will execute commands both during the image build process and when running the...
Card Puncher Data Processing
Dockerfile - Variable / env

This page talks OS/Shell Environment variable in dockerfile. Unlike an ARG instruction, ENV values are always persisted in the built image. Docker variable expansion works the same than variable...
Card Puncher Data Processing
VM - Container (Ligthweight VM)

A container is the logical OS equivalent of a process in a virtual environment. They share: an operating system installed on the server and run resource-isolated (Each container has isolated environment...



Share this page:
Follow us:
Task Runner