Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmservera/min
Smallest possible Docker image
https://github.com/jmservera/min
Last synced: 8 days ago
JSON representation
Smallest possible Docker image
- Host: GitHub
- URL: https://github.com/jmservera/min
- Owner: jmservera
- License: mit
- Created: 2021-11-12T00:19:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-08T11:04:24.000Z (almost 3 years ago)
- Last Synced: 2024-04-13T03:17:43.708Z (9 months ago)
- Language: Assembly
- Size: 981 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minimal Docker image to explain Docker from the beginning
The smallest possible Docker image contains a Hello World application that avoids libc so has 0 dependencies and uses less than 9kB.
> Take a look at [linux syscall](https://github.com/raminfp/linux_syscall/blob/master/C_syscall_without_standard_library_linux/assm_syscall.c) for a Hello World without libc.
You can create the image with `docker build -t minimal .`
## More examples
The `Dockerfile.compiler` creates the same minimal image, but uses a multibuild stage to compile the C program using gcc. Build this one with `docker build -t minimal -f Dockerfile.compiler .`.
To be able to see what's into the image, you need some more basic libraries and tools. These are provided with the `Dockerfile.sh` one, where we provide a bin folder with the `sh` executable, and the lib and lib64 folders with the libc libraries needed for sh.
Create the image with `docker build -t minsh -f Dockerfile.sh .`, and run it with `docker run -it minsh sh`.
## Navigating the Linux shell without any tool
With the last image, there's only the sh and hello executables. But you can still do some basic things with the shell:
* `cd` to change the current directory
* `echo *` to list the files in the current directory
* `pwd` to show the current directory
* You can create a cat command with this shell function:
```sh
cat() {
while read line;
do echo $line
done < $1
}
```
* Now you can do `cat /proc/version` to see the kernel version or `cat /proc/sys/kernel/hostname` to see the hostname.