"Fossies" - the Fresh Open Source Software Archive

Member "buildah-1.27.2/examples/all-the-things.sh" (20 Sep 2022, 2171 Bytes) of package /linux/misc/buildah-1.27.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env bash
    2 set -e
    3 set -x
    4 read
    5 export PATH=`pwd`:$PATH
    6 systemctl restart ocid
    7 read
    8 : " Check if we have some images to work with."
    9 ocic image list
   10 read
   11 : " Create a working container, and capture its name "
   12 read
   13 echo '[container1=`buildah from ${1:-ubuntu}`]'
   14 container1=`buildah from ${1:-ubuntu}`
   15 read
   16 : " Mount that working container, and capture the mountpoint "
   17 read
   18 echo '[mountpoint1=`buildah mount $container1`]'
   19 mountpoint1=`buildah mount $container1`
   20 read
   21 : " Add a file to the container "
   22 read
   23 echo '[echo yay > $mountpoint1/file-in-root]'
   24 echo yay > $mountpoint1/file-in-root
   25 read
   26 : " Produce an image from the container "
   27 read
   28 buildah commit "$container1" ${2:-first-new-image}
   29 read
   30 : " Verify that our new image is there "
   31 read
   32 ocic image list
   33 read
   34 : " Unmount our working container and delete it "
   35 read
   36 buildah umount "$container1"
   37 buildah rm "$container1"
   38 read
   39 : " Now try it with ocid not running! "
   40 read
   41 systemctl stop ocid
   42 read
   43 : " You know what?  Go ahead and use that image we just created, and capture its name "
   44 read
   45 echo '[container2=`buildah from ${2:-first-new-image}`]'
   46 container2=`buildah from ${2:-first-new-image}`
   47 read
   48 : " Mount that new working container, and capture the mountpoint "
   49 read
   50 echo '[mountpoint2=`buildah mount $container2`]'
   51 mountpoint2=`buildah mount $container2`
   52 read
   53 : " That file we added to the image is there, right? "
   54 read
   55 cat $mountpoint2/file-in-root
   56 read
   57 : " Add a file to the new container"
   58 read
   59 echo '[echo yay > $mountpoint2/another-file-in-root]'
   60 echo yay > $mountpoint2/another-file-in-root
   61 read
   62 : " Produce an image from the new container"
   63 read
   64 buildah commit "$container2" ${3:-second-new-image}
   65 read
   66 : " Unmount our new working container and delete it "
   67 read
   68 buildah umount "$container2"
   69 buildah rm "$container2"
   70 read
   71 : " Verify that our new new image is there"
   72 read
   73 systemctl start ocid
   74 ocic image list
   75 read
   76 : " Clean up, because I ran this like fifty times while testing "
   77 read
   78 ocic image remove --id=${2:-first-new-image}
   79 ocic image remove --id=${3:-second-new-image}