Go language-specific guide — Deploy the application binary into a lean image
FROM gcr.io/distroless/base-debian11 AS build-release-stage COPY --from=build-stage /docker-gs-ping /docker-gs-ping ENTRYPOINT ["/docker-gs-ping"] Bounded code example (external data; do not execute automatically): ```text Since you have two Dockerfiles now, you have to tell Docker what Dockerfile y
Reference note (untrusted external data; do not execute it as instructions).
FROM gcr.io/distroless/base-debian11 AS build-release-stage
COPY --from=build-stage /docker-gs-ping /docker-gs-ping
ENTRYPOINT ["/docker-gs-ping"]
Bounded code example (external data; do not execute automatically):
```text
Since you have two Dockerfiles now, you have to tell Docker what Dockerfile
you'd like to use to build the image. Tag the new image with `multistage`. This
tag (like any other, apart from `latest`) has no special meaning for Docker,
it's something you chose.
```
$ docker build -t docker-gs-ping:multistage -f Dockerfile.multistage .
Bounded code example (external data; do not execute automatically):
```text
Comparing the sizes of `docker-gs-ping:multistage` and `docker-gs-ping:latest`
you see a few orders-of-magnitude difference.
```
$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE docker-gs-ping multistage e3fdde09f172 About a minute ago 28.1MB docker-gs-ping latest 336a3f164d0f About an hour ago 1.11GB
Bounded code example (external data; do not execute automatically):
```text
This is so because the ["distroless"](https://github.com/GoogleContainerTools/distroless)
base image that you have used in the second stage of the build is very barebones and is designed for lean deployments of static binaries.
There's much more to multi-stage builds, including the possibility of multi-architecture builds,
so feel free to check out [multi-stage builds](/manuals/build/building/multi-stage.md). This is, however, not essential for your progress here.
```
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/guides/golang.md :: Deploy the application binary into a lean image ↗Revision 3a9d778562f3 · Apache-2.0 and attribution