Passing Red Hat EX401

By passing Red Hat EX401, I thought of sharing my experience and the study notes I took in order to pass this exam.

First things first, I must say that I won’t be sharing anything about the exam itself as this will be a breach of the NDA. Also I want to highlight that I’ve used satellite and spacewalk over the past 3 years a lot, did a lot of administration and numerous installations, so this helped a lot in studying.

Also I was certified on Satellite 5.6, and as Satellite 6 will be released in the next few months, so this review will be specifically on 5.6 because 6 will be totally different and will involve new components such as Puppet, foreman and katello.

As with all Red Hat exams, Red Hat EX401 is a performance based exam, you get multiple tasks which you must perform and the task should persist across reboots and without intervention of anyone.

I took the exam without attending the training course so it was a self study effort, and will do the same with all the other RHCA exams that I am planning to take.

So how did I study?

From the official documentation provided by Red Hat, the documentation is very thorough and covers everything about satellite.

How to plan for studying?

First review the Study points for Red Hat EX401 and get very familiar with them, I was checking these points almost daily and making sure that they are thoroughly covered during my studies. Trust me they are very important. And I made sure to practice them almost every three or four days.

The lab

Satellite is provided by Red Hat and you will need to get in touch with them in order to obtain the software, here comes the but part, but there is the upstream open source project from Satellite, which is Spacewalk, it’s freely available and it’s there is almost no difference between the two. Although the newer versions of Spacewalk have a bit different UI, it’s rather the same and simple to use.

I practiced on virtual machines that I created on my laptop, mainly I create a virtual machine then take a snapshot, then perform an installation then a snapshot, then perform some of the tasks in the study points then a snapshot, and so on. Why? to revert back to any snapshot and perform the tasks again.

One thing I must highlight though is that you have to be very comfortable in creating RPMs from source code, I already build RPM’s so I was very familiar with the concept, but in case you haven’t created RPM’s before, you need to practice a lot.

Final preparation

The day before the exam, I imagined myself sitting in the exam room and the exam in front of me, what would I do? I have to accomplish all the study points in 4 hours, so that’s what I did. I performed all points in just 2 hours, practicing will make you accomplish even better times.

Red Hat EX401

The exam itself isn’t hard, and actually I finished before half the time, three things though:

  • You have to organize and manage your time very well
  • You will have enough time to test everything again
  • Don’t panic and keep relaxed

And best of luck to everyone.

Dockerizing nginx

Now that we have images ready, let’s start dockerizing some applications to play with. I will start with dockerizing nginx and serve some static html content from it.

To dockerize an application, you need 2 things:

      1. The base image which will be used to build the new image from
      2. A dockerfile

Now what’s a dockerfile?

Dockerfile is a text file that describes how and what will the new image do. It contains command that you would execute normally when installing and configuring applications.

Dockerizing nginx

Now the first thing is to choose which image you want to build nginx on. I’ll choose the previously created image from Debian Wheezy.

So let’s start writing our Dockerfile…

I always put some description, the author and the usage of the image on the top, so create a new file (nginx.docker) and put:

# nginx: Dockerfile for building nginx images
# Based on aossama/wheezy
#
# Version 0.1
#
# Author "Ahmed Ossama <ahmed@aossama.com>

FROM aossama/wheezy
MAINTAINER Ahmed Ossama "ahmed@aossama.com"

RUN \
	apt-get update && apt-get -y upgrade && \
	apt-get install -y nginx-full && \
	echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
	mkdir /data && chown -R www-data:www-data /data && \
	echo 'root:0101848876' | chpasswd

# Expose ports
EXPOSE 80
EXPOSE 443

# Define mountable directories.
VOLUME [ "/data", "/etc/nginx/sites-enabled", "/var/log/nginx"]

# Define working directory
WORKDIR /etc/nginx

# Define default command
CMD ["nginx"]


Now this is a simple docker file which builds layers of images in these steps:

      1. A new image FROM aossama/wheezy
      2. With a maintainer details
      3. After than run these commands in a new container
      4. Then expose port 80
      5. And port 443
      6. The image should have these mount points available
      7. When the container starts, use this working directory by default
      8. Finally run nginx

Now build the new image:

$ cat nginx.docker | docker build -t aossama/nginx -

And inspect the images, if the build finish successfully you should find the new image in the list.

$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
aossama/nginx latest a1523342e224 7 minutes ago 336.7 MB

Your image is ready to run in a container, to run it:

$ docker run -d --name=nginx aossama/nginx 
4fa1e7cf65e6b50f77403418c57e12a4cd3cf243c685d9d27faa47ed742b5398
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
4fa1e7cf65e6        aossama/nginx:latest        nginx               4 seconds ago       Up 3 seconds        443/tcp, 80/tcp     nginx

Inspect the new image and grep the IP address:

$ docker inspect nginx | grep IPAddress
	"IPAddress": "172.17.0.3",

If you opened a browser and point to this IP address, you should see the welcome page of nginx.

Build RHEL Docker Image from Scratch

docker

 

 

 

 

 

 

This article covers how to build a RHEL6 docker image from scratch and use it in docker. In order to build this image you either should have access to RHN or have DVD to install the base system from. I’ll be installing it from a DVD.

We’ll be using yum and rpm to initialize the image’s root directory.

Build RHEL Image

First install yum and rpm

$ sudo apt-get install yum rpm

Next step is to initialize the RPM database so that we can install all of the software we need in the image: we will need to create the directory for the database because RPM expects it to exist, and then use the RPM “rebuilddb” command:

$ rhel6_root=/vdisks/chroot/rhel6
$ mkdir -p ${rhel6_root}/var/lib/rpm
$ sudo rpm --root $rhel6_root --initdb

In order for YUM to manage and install software into our image it needs to know which RHEL version to install – for this the package redhat-release to be installed in the image.

$ sudo rpm --root ${rhel6_root} -ivh /mnt/cdrom/Packages/redhat-release*

Next configure YUM repository

$ cat ${rhel6_root}/etc/yum.repos.d/rhel-dvd.repo
[rhel-dvd]
name=Red Hat Enterprise Linux $releasever - $basearch - DVD
baseurl=file:///mnt/cdrom

Now install yum and rpm in the image

$ sudo yum -y --installroot=${rhel6_root} install yum rpm

At this point you have a small environment which you can chroot into and modify it the way you like

$ sudo chroot ${rhel6_root} /bin/bash

You will drop to a bash shell in the newly created system, I won’t do any further changes to this system except modifying the banner

# echo 'RHEL 6 Docker image' > /etc/motd
# exit

Import Docker Image

Now let’s import this new system into docker:

$ sudo tar -C rhel6/ -c . | docker import - aossama/rhel6
f013651179cf1192375f66f20f0f61246aaa60c462a60ff03a3d524c58123ae8

If the import goes well, you will see the ID of the newly imported image

First check the images list:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
aossama/rhel6       latest              f013651179cf        19 seconds ago      268.4 MB

And start the new image

$ docker run --rm --name=rhel6 aossama/rhel6 cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)

$ docker run --rm --name=rhel6 aossama/rhel6 cat /etc/motd
RHEL 6 Docker image

And voilĂ , you just built a RHEL6 docker image, imported it, and ready to dockerize it.

Build Debian Docker Image from Scratch

docker

 

 

 

 

 

 

Now that we have practiced some basic operations with Docker, let’s create, import and start an image. This article covers how to build a Debian docker image from scratch and use it in docker.

We’ll be using the famous debootstrap tool which installs a Debian base system into a subdirectory of another, already installed system.

Build Wheezy

First install debootstrap

$ sudo apt-get install debootstrap

Then prepare the root directory

$ mkdir -p /vdisks/chroot/wheezy

Finally build a Wheezy system

$ sudo debootstrap wheezy /vdisks/chroot/wheezy http://ftp.us.debian.org/debian

At this point you have a small environment which you can chroot into and modify it the way you like

$ sudo chroot /vdisks/chroot/wheezy /bin/bash

You will drop to a bash shell in the newly created system, I won’t do any further changes to this system except modifying the banner

# echo "Debian 7 Docker image" > /etc/motd
# exit

Import Docker Image

Now let’s import this new system into docker:

$ sudo tar -C wheezy/ -c . | docker import - aossama/wheezy
cec2131b98fdfd41d83437509fea930a949f7cd074b66c36a0a6def8e26b5d02

If the import goes well, you will see the ID of the newly imported image

First check the images list:

$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
aossama/wheezy latest cec2131b98fd 2 minutes ago 218.6 MB

And start the new image

$ docker run --rm --name=wheezy aossama/wheezy cat /etc/motd
Debian 7 Docker image

And voilĂ , you just built a new docker image, imported it, and ready to dockerize it.

Practical Introduction to Docker Operations

Docker

 

 

 

 

 

 

After having a quick introduction on Docker, let’s have a practical introduction to Docker operations.

Installation

Debian 8 comes with a 3.14.0 Linux kernel, and a docker.io package which installs all its prerequisites from Debian’s repository.

To install the latest Debian package (may not be the latest Docker release):

$ sudo apt-get update
$ sudo apt-get install docker.io

Giving non-root access

$ sudo usermod -a -G docker aossama

Log in to the Hosted Docker Registry

First sign up at: https://hub.docker.com/account/signup/

Once you have created an account, you will need to login from the command line

$ docker login

Search for an image

Search for all repositories in Docker hub with the word “debian” in their name

$ docker search debian

Pull an image

This will pull the latest aossama/debian image from the remote repository and cache it in the local index. If the image you are pulling is made up of layers, all of the layers will be pulled.

$ docker pull aossama/debian

List images

This will list all of the images in the local index.

$ docker images

Tag an Image

Tag an image into a repository. It’s easier to deal with images if they are tagged with simple names.

$ docker tag aossama/debian debian

Run a Container

Run a command in a new container

$ docker run -i -t -rm --name="debian" google/debian cat /etc/debian_version

List containers

This will list all of the containers that are running or stopped

$ docker ps -a

Remove a container

First make sure that the container is stopped, then;

$ docker rm debian

Remove an image

First make sure that no containers are using the image, then;

$ docker rmi google/debian