Simple Go binary -> tiny Docker image
$ ID=$( docker run -d -p 80:8080 rackerlabs/whoa )
$ curl $( docker port $ID 8080 )
š Whoa! š
You'll need go with cross compiling support (and make)!
$ make
The whoa binary that gets built is built specifically to be smallā , courtesy
@kelseyhightower.
$ CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w' .
Assuming everything is happy in go land, that should create a whoa binary.
The Dockerfile relies on the super tiny scratch imageā ,
adding the whoa server as one of its steps:
FROM scratch
EXPOSE 8080
ADD whoa /whoa
ENTRYPOINT ["/whoa"]
The resulting Docker image is < 5 MB:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
rackerlabs/whoa latest 5ad725856153 About an hour ago 4.437 MB
How 'bout them š?
Content type
Image
Digest
sha256:342998585ā¦
Size
1.2 MB
Last updated
about 11 years ago
docker pull rackerlabs/whoa