liveBook · Manning

Application stage

As explained in Learn Docker in a Month of Lunches, Second Edition

An application stage is a Dockerfile build stage that assembles the runtime image for an application.

An application stage is the final stage in a multi-stage Dockerfile. It assembles the runtime image from a minimal base image, application files, configuration, and artifacts copied from a builder stage. section 4.4

A Go application stage typically:

  • Uses a small runtime base such as diamol/base:2e instead of the Go toolset image. section 4.4
  • Sets environment variables and a startup command for the application. section 4.4
  • Copies static HTML from the host and the compiled server from the builder stage. section 4.4
  • Marks the server executable with chmod on Linux; the command has no effect on Windows. section 4.4

Go runtime stage

FROM diamol/base:2e ENV IMAGE_API_URL="http:/./iotd/image" \ ACCESS_API_URL="http:/./accesslog/access-log" CMD ["/web/server"] WORKDIR web COPY index.html . COPY --from=builder /server . RUN chmod +x server section 4.4

Listing 4.4 Dockerfile for building a Go application from source
FROM diamol/golang:2e AS builder

COPY go.mod main.go /go/
RUN go build -o /server

# app
FROM diamol/base:2e

ENV IMAGE_API_URL="http:/./iotd/image" \
    ACCESS_API_URL="http:/./accesslog/access-log"
CMD ["/web/server"]

WORKDIR web
COPY index.html .
COPY --from=builder /server .
RUN chmod +x server

Browse the complete Dockerfile, including the builder stage and the final application stage. section 4.4

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains base-image selection, configuration, artifact copying, startup, and executable permissions without detailing Docker internals.
Examples
Uses a Go server, index.html, diamol/base:2e, cross-stage copying, chmod, and image-size comparison.
What you can do after
Builds a Go runtime image with Docker using a compiled server, static content, environment variables, and a startup command.
How it connects
Connects multi-stage builds with builder stages, runtime images, environment variables, startup commands, and file permissions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.