2014-08-19

Test RHEL7 without installing it - on Docker!

So there's this new interesting operating system you'd like to try out? Traditionally you had to find a spare laptop where to install it on, and later on you installed them on virtual machines running on your laptop.

Nowadays things are even more easy; Docker provides an easy way to create software containers without you having to provision virtual machines or having to hunt for spare laptops.

Currently I'm running Fedora 20 on my laptop and in order to demonstrate stuff on RHEL7 all I need to do is to launch a RHEL7 in a container using Docker.

Couple of easy steps to test it out yourself:

Install Docker
On Fedora the RPM package is called "docker-io", let's install it first:

yum install docker-io

Add yourself to the Docker group so you don't need to use sudo later on:

sudo usermod -a -G docker $USER

Start Docker and enable it on boot time:
systemctl enable docker
systemctl start docker


Download RHEL7 base image

https://access.redhat.com/search/browse/docker-images#? -> "Red Hat Enterprise Linux 7 base image container in Docker Format"

Load the image into Docker and verify it's listed:

docker load -i ~/Downloads/rhel-server-docker-7.0-21.4-x86_64.tar.gz
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
redhat/rhel         latest              e1f5733f050b        10 weeks ago        140.2 MB
rhel                latest              e1f5733f050b        10 weeks ago        140.2 MB
redhat/rhel7        0                   e1f5733f050b        10 weeks ago        140.2 MB
redhat/rhel7        0-21                e1f5733f050b        10 weeks ago        140.2 MB
redhat/rhel7        latest              e1f5733f050b        10 weeks ago        140.2 MB
rhel7               0                   e1f5733f050b        10 weeks ago        140.2 MB
rhel7               0-21                e1f5733f050b        10 weeks ago        140.2 MB
rhel7               latest              e1f5733f050b        10 weeks ago        140.2 MB

Start your RHEL7!
docker run -t -i rhel7 /bin/bash
bash-4.2# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)
bash-4.2# 

So what just happened? We told Docker to run "rhel7" image and start "/bin/bash". Option -t allocates a pseudo-tty (terminal) and -i is interactive mode. If you forget the flags your image is started in background.

You can use docker ps command to list running images, common use case is to open another terminal to do this while your image is running:

docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
9469ec5c152b        redhat/rhel7:0      /bin/bash           4 seconds ago       Up 2 seconds                            distracted_ritchie   

Next steps

You'll probably want to learn about creating your own layered images, creating services within the image such as Apache or MySQL etc.

One good place to start learning is the Red Hat customer portal: https://access.redhat.com/articles/881893 "Get Started with Docker Containers in RHEL 7".


 

No comments:

Post a Comment