Dockerfiles: Basic Example

Docker

A very basic example of a Dockerfile might look something like this:

# escape=`

ARG BASE_IMAGE

FROM ${BASE_IMAGE}

WORKDIR C:\inetpub\wwwroot

COPY .\testfile.txt .\

Line by line, it does the following:

  1. The escape directive sets the character used to escape characters in a Dockerfile. If not specified, the default escape character is \.
  2. Specifies that the Dockerfile allows an argument called 'BASE_IMAGE'
  3. Specifies that we use the provided argument BASE_IMAGE as the base layer for the new image.
  4. Sets the working directory to “C:\inetpub\wwwroot
  5. Copies the file testfile.txt from the root of the supplied ‘Context' to the root of the 'Working Directory’.

If this file is then built, the resulting image would be saved (with no name) to the local docker image store.

Build an image from this Dockerfile

For more information on how you would build this Dockerfile and create a new image, see this page Docker Build Command

Leave a Reply

Your email address will not be published. Required fields are marked *