Performance Checklist
In this lab, you will use the new container runtime to build and run a custom container.
Outcomes
You should be able to build and deploy a custom container using the new container runtime.
Install the new container runtime software packages on servera.
Build a new container from scratch on servera and label it custom-container.
Use buildah to create a new container from scratch.
[root@servera ~]#buildah from scratchworking-container
List the available containers.
[root@servera ~]#buildah containersCONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME bc4c2a71c4c9 * scratch working-container
Label the newly created container custom-container.
[root@servera ~]#buildah config --label name=custom-container working-container
Inspect the container.
[root@servera ~]#buildah inspect working-container...output omitted..."Container": "working-container","ContainerID": "bc4c2a71c4c9fbb11b7b88127a67173b82d0e4f95e7935c4a36b8d3010b8de16", "MountPoint": "", "ProcessLabel": "", "MountLabel": "", "ImageAnnotations": null, "ImageCreatedBy": "", "OCIv1": { "created": "2019-02-07T05:24:20.845648888Z", "architecture": "amd64", "os": "linux", "config": {"Labels": {"name": "custom-container"...output omitted...
Prepare the new container for installing software on servera.
Mount the root file system of working-container.
Verify the correct mount point for your case.
[root@servera ~]#buildah mount working-container/var/lib/containers/storage/overlay/14e1...fbed/merged
Initialize the RPM database within the container.
[root@servera ~]#rpm --root \>/var/lib/containers/storage/overlay/14e1...fbed/merged \>--initdb
Download the redhat-release-server RPM on servera.
[root@servera ~]#yum install yum-utils...output omitted...Is this ok [y/N]:y...output omitted...
[root@servera ~]#yumdownloader --destdir=/tmp redhat-release-server...output omitted... redhat-release-8.0-0.44.el8.x86_64.rpm 3.4 MB/s | 45 kB 00:00
Install the redhat-release-server RPM on working-container.
[root@servera ~]#rpm -ivh \>--root /var/lib/containers/storage/overlay/14e1...fbed/merged \>/tmp/redhat-release*.rpm...output omitted... Updating / installing... 1:redhat-release-8.0-0.44.el8 ################################# [100%]
Copy the local repository file to the working-container mount point.
[root@servera ~]#cp \>/etc/yum.repos.d/rhel_dvd.repo \>/var/lib/containers/storage/overlay/14e1...fbed/merged/etc/yum.repos.d/
Customize the new container to run an apache web server, with some text content and listening on TCP port 80, on servera.
Install the httpd package in the container.
[root@servera ~]#yum install \>--installroot /var/lib/containers/storage/overlay/14e1...fbed/merged \>httpd...output omitted...Is this ok [y/N]:y...output omitted... Complete!
Create some text content and expose it as an index.html on working-container mount directory.
[root@servera ~]#echo "custom-container Working OK" > \>/var/lib/containers/storage/overlay/14e1...fbed/merged/var/www/html/index.html
Configure /usr/sbin/httpd as the first command to run in working-container.
[root@servera ~]#buildah config --cmd "/usr/sbin/httpd -DFOREGROUND" \>working-container
Configure the internal listening port for httpd daemon in working-container.
[root@servera ~]#buildah config --port 80/tcp working-container
Clean up the Yum cache on the working-container container.
[root@servera ~]#yum clean all \>--installroot /var/lib/containers/storage/overlay/14e1...fbed/merged \...output omitted...
Unmount the root file system of working-container.
[root@servera ~]#buildah unmount working-container14e1392a5a7d06da689e26c1438b9092008f9c012affbae943ee25720ecbfbed
Create a new container image based on your custom container and name it custom-image, on servera.
Create the container image custom-image based on the working-container container.
[root@servera ~]#buildah commit working-container custom-imageGetting image source signatures Copying blob sha256:02f83791177ef46b84dfbf49d491971a9a83f793af08a507c1a744f842366010 144.82 MiB / 144.82 MiB [==================================================] 9s Copying config sha256:09901c90da2a4ea033e8083316983605e09dd34860729f1047f2d78ecea06558 332 B / 332 B [============================================================] 0s Writing manifest to image destination Storing signatures 09901c90da2a4ea033e8083316983605e09dd34860729f1047f2d78ecea06558
List the available images on servera.
[root@servera ~]#buildah imagesIMAGE NAME IMAGE TAG IMAGE ID CREATED AT SIZElocalhost/custom-imagelatest 09901c90da2a Feb 6, 2019 22:22 483 MB
Deploy and test a container based on the new custom container image, on servera.
Run a container based on the localhost/custom-image image.
[root@servera ~]#podman run -d -p 80:80 --name lab-container localhost/custom-image1aedf5420e73b71105b02bc7fdbea406b3313ec29bde7fa3f661c1ccf4fc1a7a
Test the container httpd daemon.
[root@servera ~]#curl localhostcustom-container Working OK
Use firewalld to open the HTTP service port on servera.
[root@servera ~]#firewall-cmd --add-service=httpsuccess
Try accessing the web server running inside the container from serverb.
When done, log off from serverb.
Clean up the exercise data on servera.
When done, log off from servera.
Switch to the servera terminal, and stop the running container.
[root@servera ~]#podman stop lab-container1aedf5420e73b71105b02bc7fdbea406b3313ec29bde7fa3f661c1ccf4fc1a7a
Delete the container on servera.
[root@servera ~]#podman rm lab-container1aedf5420e73b71105b02bc7fdbea406b3313ec29bde7fa3f661c1ccf4fc1a7a
Delete the container image on servera.
[root@servera ~]#podman rmi localhost/custom-imagea8fe25c677f2878d73ace848d7fd2f2bf06f1470c94e33fee9a444eecd8e49d9
Delete the working-container container on servera.
[root@servera ~]#buildah delete working-containerbc4c2a71c4c9fbb11b7b88127a67173b82d0e4f95e7935c4a36b8d3010b8de16
Log off from servera.
[root@servera ~]#exit[student@workstation ~]$
This concludes the lab.