$ docker images |grep tiny-hello
tiny-hello latest 21d5b79018bb 2 minutes ago 952B
-
-
Save tonymet/a80595400b8481e8a0274d63c290ceec to your computer and use it in GitHub Desktop.
ultra-tiny 1kB docker images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.o | |
hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest as builder | |
WORKDIR /build | |
RUN apk update && \ | |
apk add nasm make binutils | |
COPY . ./ | |
RUN make hello | |
FROM scratch | |
WORKDIR / | |
COPY --from=builder /build/hello . | |
CMD ["/hello"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Define variables in the data section | |
SECTION .DATA | |
hello: db 'Hello world!',10 | |
helloLen: equ $-hello | |
; Code goes in the text section | |
SECTION .TEXT | |
GLOBAL _start | |
_start: | |
mov eax,4 ; 'write' system call = 4 | |
mov ebx,1 ; file descriptor 1 = STDOUT | |
mov ecx,hello ; string to write | |
mov edx,helloLen ; length of string to write | |
int 80h ; call the kernel | |
; Terminate program | |
mov eax,1 ; 'exit' system call | |
mov ebx,0 ; exit with error code 0 | |
int 80h ; call the kernel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello.o: hello.asm | |
nasm -f elf64 $< -o $@ | |
hello: hello.o | |
ld $< -o $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment