- Name
jhermann/gohi
- Description
A golang multi-stage build container image example.
- Maintainer
Jürgen Hermann <[email protected]>
The following commands build and run a golang binary from the source in hi.go
, putting it into a from-scratch Docker image.
docker build -t jhermann/gohi -t jhermann/gohi:$(git describe --tags) .
docker run --rm -it jhermann/gohi
It doesn't get easier than this. ☺
The resulting image is only slightly larger than the contained golang binary.
$ dockviz images --tree jhermann/gohi
└─927b6ad2e4fa Virtual Size: 1.4 MB Tags: jhermann/gohi:latest, jhermann/gohi:v0-1-g93bf073
To look at the image's metadata, use docker inspect
:
docker inspect jhermann/gohi:latest | jq -CS
Leave out the jq
part if you don't have that installed, it just colorizes the output.
Using prom/busybox:glibc instead of scratch adds 6 MB in size, a shell, and the other debugging and introspection conveniences of a full base image.