Skip to main content

SystemTap: Provisioning an AWS EC2-Based Docker Instance

In the first article in our SystemTap series, we learned how to install the powerful diagnostic tool, SystemTap, on an AWS EC2 instance and then wrote our very first “Hello World” script. We now need to explore some of the interesting (and more useful) scripts that come with SystemTap.

Building a SystemTap target environment

To make this article easier to read, we will split it into two parts. In this post, we will provide a Red Hat Enterprise Linux 7 platform container image with Docker on an AWS EC2 instance. After the SystemTap target environment is properly built, the final part will show how to run some serious scripts on a Docker container from its EC2 host to illustrate just how useful SystemTap can be.

Installing Docker on your AWS EC2 instance

To install Docker on an AWS EC2 instance, we’ll enable the “Red Hat Enterprise Linux Server 7 Extra(RPMs)” yum repository that, by default, is disabled.

$ sudo yum repolist disabled
Loaded plugins: amazon-id, rhui-lb
repo id                                                          repo name
rhui-REGION-rhel-server-debug-extras/7Server/x86_64              Red Hat Enterprise Linux Server 7 Extra Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-optional/7Server/x86_64            Red Hat Enterprise Linux Server 7 Optional Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-rh-common/7Server/x86_64           Red Hat Enterprise Linux Server 7 RH Common Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-rhscl/7Server/x86_64               Red Hat Enterprise Linux Server 7 RHSCL Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-supplementary/7Server/x86_64       Red Hat Enterprise Linux Server 7 Supplementary Debug (Debug RPMs)
rhui-REGION-rhel-server-extras/7Server/x86_64                    Red Hat Enterprise Linux Server 7 Extra(RPMs)
rhui-REGION-rhel-server-optional/7Server/x86_64                  Red Hat Enterprise Linux Server 7 Optional (RPMs)
rhui-REGION-rhel-server-releases-source/7Server/x86_64           Red Hat Enterprise Linux Server 7 (SRPMs)
rhui-REGION-rhel-server-rhscl/7Server/x86_64                     Red Hat Enterprise Linux Server 7 RHSCL (RPMs)
rhui-REGION-rhel-server-source-extras/7Server/x86_64             Red Hat Enterprise Linux Server 7 Extra (SRPMs)
rhui-REGION-rhel-server-source-optional/7Server/x86_64           Red Hat Enterprise Linux Server 7 Optional (SRPMs)
rhui-REGION-rhel-server-source-rh-common/7Server/x86_64          Red Hat Enterprise Linux Server 7 RH Common (SRPMs)
rhui-REGION-rhel-server-source-rhscl/7Server/x86_64              Red Hat Enterprise Linux Server 7 RHSCL (SRPMs)
rhui-REGION-rhel-server-source-supplementary/7Server/x86_64      Red Hat Enterprise Linux Server 7 Supplementary (SRPMs)
rhui-REGION-rhel-server-supplementary/7Server/x86_64             Red Hat Enterprise Linux Server 7 Supplementary (RPMs)
repolist: 0

We’ll use the yum-config-manager to enable the repo:

$ sudo yum-config-manager --enable "Red Hat Enterprise Linux Server 7 Extra(RPMs)"

Next, you should search for the Docker package and install it. Yum will take care of its dependencies.

$ sudo yum search docker
Loaded plugins: amazon-id, rhui-lb
rhui-REGION-rhel-server-extras                                                                                    | 2.9 kB  00:00:00
rhui-REGION-rhel-server-releases                                                                                  | 3.7 kB  00:00:00
rhui-REGION-rhel-server-releases-debug                                                                            | 2.9 kB  00:00:00
rhui-REGION-rhel-server-rh-common                                                                                 | 3.8 kB  00:00:00
rhui-REGION-rhel-server-extras/7Server/x86_64/primary_db                                                          |  56 kB  00:00:00
rhui-REGION-rhel-server-extras/7Server/x86_64/updateinfo                                                          |  27 kB  00:00:00
========================================================== N/S matched: docker ==========================================================
docker-logrotate.x86_64 : cron job to run logrotate on docker containers
docker-python.x86_64 : An API client for docker written in Python
docker-registry.noarch : Registry server for Docker
docker-registry.x86_64 : Registry server for Docker
docker-selinux.x86_64 : SELinux policies for Docker
docker.x86_64 : Automates deployment of containerized applications
  Name and summary matches only, use "search all" for everything.
$ sudo yum -y install docker

Once the Docker-related packages are installed, you should enable and start the docker service.

$ sudo systemctl enable docker
ln -s '/usr/lib/systemd/system/docker.service' '/etc/systemd/system/'
$ sudo systemctl start docker
$ sudo systemctl status docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running) since Wed 2015-09-16 02:02:26 EDT; 20ms ago
 Main PID: 10738 (docker)
   CGroup: /system.slice/docker.service
           └─10738 /usr/bin/docker -d --selinux-enabled --add-registry
Sep 16 02:02:00 ip-172-30-0-123.ap-southeast-1.compute.internal systemd[1]: Starting Docker Application Container Engine...
Sep 16 02:02:00 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:00.179717121-04:00" level=inf...k)"
Sep 16 02:02:00 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:00.447391712-04:00""
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:26.342873074-04:00" level=war....10
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:26.360314551-04:00""
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:26.798683604-04:00" level=inf...t."
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:26.798853557-04:00" level=inf...e."
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:26.798869375-04:00" level=inf...on"
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal docker[10738]: time="2015-09-16T02:02:26.798882151-04:00" level=inf...7.1
Sep 16 02:02:26 ip-172-30-0-123.ap-southeast-1.compute.internal systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

In order to use Docker with the ec2-user normal user, we need to create a docker group and add ourselves in it.

$ sudo groupadd docker
$ sudo usermod -aG docker ec2-user
$ grep ^docker /etc/group

Provisioning Red Hat Enterprise Linux 7 container with Docker

To provision our container with Docker, pull down the Red Hat Enterprise Linux 7 platform container image from Red Hat.

$ docker pull rhel7
Trying to pull repository ...
82ad5fa11820: Download complete
Status: Downloaded newer image for

Run docker images to list the container we have downloaded.

$ docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE     latest              82ad5fa11820        6 days ago          158.3 MB

Let’s do a quick test to see if everything is working.

$ docker run -ti rhel7 /bin/bash
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
[root@35f99cabc19a /]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)
[root@c8a8740808c0 bin]# df -h
Filesystem                                                                                          Size  Used Avail Use% Mounted on
/dev/mapper/docker-202:2-51421425-c8a8740808c0d41b7294f6f2906543740b7a9b54791b6f5bed6a150616b18dd5  9.8G  213M  9.0G   3% /
tmpfs                                                                                               497M     0  497M   0% /dev
shm                                                                                                  64M     0   64M   0% /dev/shm
tmpfs                                                                                               497M   20K  497M   1% /run/secrets
/dev/xvda2                                                                                           10G  3.6G  6.5G  36% /etc/hosts
[root@c8a8740808c0 bin]#

So far so good! We are now ready to run some real troubleshooting scripts against our VMs…which we’ll describe in the final installment of this series.

If you want to learn more on Docker, this is your go-to course Introduction to Docker.

Introduction to Docker

Written by

Eugene Teo

Eugene Teo is a director of security at a US-based technology company. He is interested in applying machine learning techniques to solve problems in the security domain.

Related Posts

Joe Nemer
Joe Nemer
— April 1, 2019

AWS EC2 Instance Types Explained

Amazon Web Services’ resource offerings are constantly changing, and staying on top of their evolution can be a challenge. Elastic Cloud Compute (EC2) instances are one of their core resource offerings, and they form the backbone of most cloud deployments. EC2 instances provide you with...

Read more
  • AWS
  • EC2
Sanket Dangi
— February 11, 2019

WaitCondition Controls the Pace of AWS CloudFormation Templates

AWS's WaitCondition can be used with CloudFormation templates to ensure required resources are running.As you may already be aware, AWS CloudFormation is used for infrastructure automation by allowing you to write JSON templates to automatically install, configure, and bootstrap your ...

Read more
  • AWS
  • formation
Andrew Larkin
— January 24, 2019

The 9 AWS Certifications: Which is Right for You and Your Team?

As companies increasingly shift workloads to the public cloud, cloud computing has moved from a nice-to-have to a core competency in the enterprise. This shift requires a new set of skills to design, deploy, and manage applications in cloud computing.As the market leader and most ma...

Read more
  • AWS
  • AWS certifications
Andrew Larkin
— November 28, 2018

Two New EC2 Instance Types Announced at AWS re:Invent 2018 – Monday Night Live

The announcements at re:Invent just keep on coming! Let’s look at what benefits these two new EC2 instance types offer and how these two new instances could be of benefit to you. If you're not too familiar with Amazon EC2, you might want to familiarize yourself by creating your first Am...

Read more
  • AWS
  • EC2
  • re:Invent 2018
Guy Hummel
— November 21, 2018

Google Cloud Certification: Preparation and Prerequisites

Google Cloud Platform (GCP) has evolved from being a niche player to a serious competitor to Amazon Web Services and Microsoft Azure. In 2018, research firm Gartner placed Google in the Leaders quadrant in its Magic Quadrant for Cloud Infrastructure as a Service for the first time. In t...

Read more
  • AWS
  • Azure
  • Google Cloud
Khash Nakhostin
Khash Nakhostin
— November 13, 2018

Understanding AWS VPC Egress Filtering Methods

In order to understand AWS VPC egress filtering methods, you first need to understand that security on AWS is governed by a shared responsibility model where both vendor and subscriber have various operational responsibilities. AWS assumes responsibility for the underlying infrastructur...

Read more
  • Aviatrix
  • AWS
  • VPC
Jeremy Cook
— November 10, 2018

S3 FTP: Build a Reliable and Inexpensive FTP Server Using Amazon’s S3

Is it possible to create an S3 FTP file backup/transfer solution, minimizing associated file storage and capacity planning administration headache?FTP (File Transfer Protocol) is a fast and convenient way to transfer large files over the Internet. You might, at some point, have conf...

Read more
  • Amazon S3
  • AWS
Guy Hummel
— October 18, 2018

Microservices Architecture: Advantages and Drawbacks

Microservices are a way of breaking large software projects into loosely coupled modules, which communicate with each other through simple Application Programming Interfaces (APIs).Microservices have become increasingly popular over the past few years. The modular architectural style,...

Read more
  • AWS
  • Microservices
Stuart Scott
— October 2, 2018

What Are Best Practices for Tagging AWS Resources?

There are many use cases for tags, but what are the best practices for tagging AWS resources? In order for your organization to effectively manage resources (and your monthly AWS bill), you need to implement and adopt a thoughtful tagging strategy that makes sense for your business. The...

Read more
  • AWS
  • cost optimization
Stuart Scott
— September 26, 2018

How to Optimize Amazon S3 Performance

Amazon S3 is the most common storage options for many organizations, being object storage it is used for a wide variety of data types, from the smallest objects to huge datasets. All in all, Amazon S3 is a great service to store a wide scope of data types in a highly available and resil...

Read more
  • Amazon S3
  • AWS
Cloud Academy Team
— September 18, 2018

How to Optimize Cloud Costs with Spot Instances: New on Cloud Academy

One of the main promises of cloud computing is access to nearly endless capacity. However, it doesn’t come cheap. With the introduction of Spot Instances for Amazon Web Services’ Elastic Compute Cloud (AWS EC2) in 2009, spot instances have been a way for major cloud providers to sell sp...

Read more
  • AWS
  • Azure
  • Google Cloud
  • SpotInst
Guy Hummel and Jeremy Cook
— August 23, 2018

What are the Benefits of Machine Learning in the Cloud?

A Comparison of Machine Learning Services on AWS, Azure, and Google CloudArtificial intelligence and machine learning are steadily making their way into enterprise applications in areas such as customer support, fraud detection, and business intelligence. There is every reason to beli...

Read more
  • AWS
  • Azure
  • Google Cloud
  • Machine Learning