Bookmark this page

Guided Exercise: Deploying Containers with the New Container Runtime

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.

  1. Install the container software packages.

    1. Log in to servera as the root user.

      [student@workstation ~]$ ssh root@servera
    2. Install the container-tools module.

      [root@servera ~]# yum module install container-tools
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
  2. Create a container from scratch and configure it to run bash. Label this container rhel-base.

    1. Create a new container from scratch.

      [root@servera ~]# buildah from scratch
      working-container
    2. Mount the root filesystem of the working-container container.

      [root@servera ~]# buildah mount working-container
      /var/lib/containers/storage/overlay/240a...b6ce/merged
    3. 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...
    4. 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
    5. Configure bash as the first command to run.

      [root@servera ~]# buildah config --cmd /bin/bash working-container
    6. Label the working-container container rhel-base.

      [root@servera ~]# buildah config --label name=rhel-base working-container
  3. Create a container image named rhel-base based on the working-container container.

    1. Unmount the working-container container.

      [root@servera ~]# buildah unmount working-container
      e6d1...2850
      
    2. 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
    3. Verify that the rhel-base container image is available.

      [root@servera ~]# buildah images
      IMAGE NAME           IMAGE TAG  IMAGE ID       CREATED AT          SIZE
      localhost/rhel-base  latest     b6d88a1866eb   Feb 4, 2019 07:20   291 MB
  4. Create a new container with the rhel-base container image.

    1. 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...
    2. 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/bash
      bash-4.4# exit
      exit
      [root@servera ~]# 
  5. Remove the working-container container and the rhel-base container image. When done, log off from servera.

    1. Remove the working-container container.

      [root@servera ~]# buildah rm working-container
      e724...797f
    2. Remove the rhel-base container image.

      [root@servera ~]# buildah rmi rhel-base
      ...output omitted...
    3. Log off from servera.

      [root@servera ~]# exit
      [student@workstation ~]$ 

This concludes the guided exercise.

Revision: rh354-8.0-0e36520