-
-
Save yodamaster/e4cf54c52f31af4171c479d6cad153df to your computer and use it in GitHub Desktop.
How to build a simple and minimalistic BusyBox Docker image from scratch, without pulling it from Docker Hub
This file contains hidden or 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
| #!/usr/bin/env sh | |
| if [ -d rootfs ] | |
| then | |
| rm -rf rootfs/ | |
| fi | |
| mkdir rootfs | |
| mkdir rootfs/bin | |
| mkdir rootfs/etc | |
| mkdir rootfs/root | |
| if [ ! -f busybox ] | |
| then | |
| wget https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox | |
| fi | |
| chmod +x busybox | |
| echo "root:x:0:0:root:/root:/bin/sh" > rootfs/etc/passwd | |
| echo "root:x:0:" > rootfs/etc/group | |
| docker build . -t simplebusybox | |
| rm -rf rootfs/ | |
| rm busybox | |
| docker run -it simplebusybox |
This file contains hidden or 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 scratch | |
| COPY rootfs/ / | |
| COPY busybox /bin | |
| RUN ["./bin/busybox", "--install", "-s", "/bin"] | |
| CMD ["/bin/sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment