Sign inSign up

bennettp123/hello-world

By bennettp123

•Updated over 7 years ago

An experiment to see how small an image can be made, while still actually doing something.

Image
0

1.3K

bennettp123/hello-world repository overview

⁠An image from scratch

This is an experiment to see how small an image can be made, while still actually doing something.

This Dockerfile produces an image that is 14k in size.

FROM alpine:3.9
RUN apk add --no-cache gcc libc-dev
COPY main.c .
RUN gcc -Os -o main -static main.c && strip main

FROM scratch
COPY --from=0 main .

CMD ["./main"]

For reference, the busybox image is 1.1M, so this is considerably smaller.

It's not as small as the official hello-world example, though. That's only 1.8k!

$ docker build -t bennettp123/hello-world .
$ docker run --rm -it bennettp123/hello-world
Hello World
$ docker image inspect foo --format='{{.Size}}'
14610

Also available on docker hub:

docker pull bennettp123/hello-world

Tag summary

Content type

Image

Digest

Size

3.8 kB

Last updated

over 7 years ago

docker pull bennettp123/hello-world