In this exercise, you will build an image and deploy it as a containerized application using the new container utilities.
Outcomes
You should be able to create a container image and deploy a container using the new container tools.
Install the container software packages.
Log in to servera as the root user.
[student@workstation ~]$ssh root@servera
Install the container-tools module.
[root@servera ~]#yum module install container-tools...output omitted...Is this ok [y/N]:y...output omitted...
Create a container from scratch and configure it to run bash.
Label this container rhel-base.
Create a new container from scratch.
[root@servera ~]#buildah from scratchworking-container
Mount the root filesystem of the working-container container.
[root@servera ~]#buildah mount working-container/var/lib/containers/storage/overlay/240a...b6ce/merged
Install the bash and the coreutils packages on the working-container container.
[root@servera ~]#yum install \>--installroot /var/lib/containers/storage/overlay/240a...b6ce/merged \>bash coreutils \>--releasever 8 \>--setopt install_weak_deps=false...output omitted...Is this ok [y/N]:y...output omitted...
Clean up the yum cache on the working-container container.
[root@servera ~]#yum clean all \>--installroot /var/lib/containers/storage/overlay/240a...b6ce/merged \>--releasever 8...output omitted... 12 files removed
Configure bash as the first command to run.
[root@servera ~]#buildah config --cmd /bin/bash working-container
Label the working-container container rhel-base.
[root@servera ~]#buildah config --label name=rhel-base working-container
Create a container image named rhel-base based on the working-container container.
Unmount the working-container container.
[root@servera ~]#buildah unmount working-containere6d1...2850
Create the rhel-base container image based on the working-container container.
[root@servera ~]#buildah commit working-container rhel-base...output omitted... Writing manifest to image destination Storing signatures b6d8...0a6a
Verify that the rhel-base container image is available.
[root@servera ~]#buildah imagesIMAGE NAME IMAGE TAG IMAGE ID CREATED AT SIZE localhost/rhel-base latest b6d88a1866eb Feb 4, 2019 07:20 291 MB
Create a new container with the rhel-base container image.
Review the specifications of the rhel-base container image.
[root@servera ~]#podman inspect localhost/rhel-base...output omitted... "Config": { "Cmd": [ "/bin/bash" ], "Labels": { "name": "rhel-base" } }, ...output omitted...
Create a container using the rhel-base container image.
Use the --rm option to delete the container when you exit it.
When done, exit the container.
[root@servera ~]#podman run --rm -it localhost/rhel-base /bin/bashbash-4.4#exitexit[root@servera ~]#
Remove the working-container container and the rhel-base container image.
When done, log off from servera.
Remove the working-container container.
[root@servera ~]#buildah rm working-containere724...797f
Remove the rhel-base container image.
[root@servera ~]#buildah rmi rhel-base...output omitted...
Log off from servera.
[root@servera ~]#exit[student@workstation ~]$
This concludes the guided exercise.