Skip to content

Instantly share code, notes, and snippets.

@yodamaster
Forked from brunocmorais/BusyboxDocker.sh
Created February 25, 2025 16:52
Show Gist options
  • Save yodamaster/e4cf54c52f31af4171c479d6cad153df to your computer and use it in GitHub Desktop.
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
#!/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
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