Create Linux OS Rootfs for Build Docker Images

2024-03-01 / Linux Docker

Create Linux OS ROOTFS

  1. Create an output folder

    # mkdir -p /output/
    
  2. Create rootfs.tar

    # cd /
    # tar cf /output/rootfs.tar --exclude=/proc --exclude=/dev --exclude=/boot --exclude=/run --exclude=/sys --exclude=/output /
    
  3. Compress tar file with xz

    # xz -v -T 0 /output/rootfs.tar
    

Build Docker Image

Build docker image from scratch with rootfs.tar.xz

FROM scratch
ADD ./rootfs.tar.xz /