Chapter 10. Red Hat Developer Toolset Images
10.1. Running Red Hat Developer Toolset Tools from Pre-Built Container Images
To display general usage information for pre-built Red Hat Developer Toolset docker-formatted container images that you have already pulled to your local machine, run the following command as root
:
# docker run image_name usage
To launch an interactive shell within a pre-built docker-formatted container image, run the following command as root
:
# docker run -ti image_name /bin/bash -l
In both of the above commands, substitute the image_name parameter with the name of the container image you pulled to your local system and now want to use.
For example, to launch an interactive shell within the container image with selected toolchain components, run the following command as root
:
# docker run -ti rhscl/devtoolset-6-toolchain-rhel7 /bin/bash -l
Example 10.1. Using GCC in the Pre-Built Red Hat Developer Toolset Toolchain Image
This example illustrates how to obtain and launch the pre-built docker-formatted container image with selected toolchain components of the Red Hat Developer Toolset and how to run the gcc
compiler within that image.
- Make sure you have a Docker environment set up properly on your system by following instructions at Getting Docker in RHEL 7.
Pull the pre-built toolchain Red Hat Developer Toolset container image from the official Red Hat Container Registry:
# docker pull rhscl/devtoolset-6-toolchain-rhel7
To launch the container image with an interactive shell, issue the following command:
# docker run -ti rhscl/devtoolset-6-toolchain-rhel7 /bin/bash -l
To launch the container as a regular (non-root) user, use the
sudo
command. To map a directory from the host system to the container file system, include the-v
(or--volume
) option in thedocker
command:$ sudo docker run -v ~/Source:/src -ti rhscl/devtoolset-6-toolchain-rhel7 /bin/bash -l
In the above command, the host’s
~/Source/
directory is mounted as the/src/
directory within the container.Once you are in the container’s interactive shell, you can run Red Hat Developer Toolset tools as expected. For example, to verify the version of the
gcc
compiler, run:bash-4.2$
gcc -v
[...] gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)
10.2. Using Container Images Built from Dockerfiles
Dockerfiles are available for selected Red Hat Developer Toolset components. Dockerfiles are text files that contain instructions for automated building of docker-formatted container images.
Red Hat Developer Toolset 6.1 for Red Hat Enterprise Linux 7 is shipped with the following Dockerfiles:
- devtoolset-6-toolchain
- devtoolset-6-perftools
10.2.1. Obtaining Dockerfiles
The Red Hat Developer Toolset Dockerfiles are provided by the package devtoolset-6-dockerfiles. The package contains individual Dockerfiles for building docker-formatted container images with individual components and a meta-Dockerfile for building a docker-formatted container image with all the components offered. To be able to use the Dockerfiles, install this package by executing:
# yum install devtoolset-6-dockerfiles
Use the RHSM channel rhel-server-rhscl-7-rpms
. In order to enable it, follow the instructions at Getting Access to Red Hat Developer Toolset.
10.2.2. Building Container Images
Change to the directory where the Dockerfile is installed and run the following command as root
:
# docker build -t image_name
Replace image_name with the desired name for the new image.
Example 10.2. Building a Container Image with a Red Hat Developer Toolset Component
To build a docker-formatted container image for deploying the perftools tools in a container, follow the instructions below:
- Make sure you have a Docker environment set up properly on your system by following instructions at Getting Docker in RHEL 7.
Install the package containing the Red Hat Developer Toolset Dockerfiles:
# yum install devtoolset-6-dockerfiles
Determine where the Dockerfile for the required component is located:
# rpm -ql devtoolset-6-dockerfiles | grep "perftools-docker/Dockerfile" /opt/rh/devtoolset-6/root/usr/share/devtoolset-6-dockerfiles/rhel7/devtoolset-6-perftools-docker/Dockerfile
Change to the directory where the required Dockerfile is installed:
# cd /opt/rh/devtoolset-6/root/usr/share/devtoolset-6-dockerfiles/rhel7/devtoolset-6-perftools-docker/
Build the container image:
# docker build -t devtoolset-6-my-perftools .
Replace devtoolset-6-my-perftools with the name you wish to assign to your resulting container image.
10.2.3. Running Red Hat Developer Toolset Tools from Custom-Built Container Images
To display general usage information for images built from Red Hat Developer Toolset Dockerfiles (see Section 10.2.2, “Building Container Images”), run the following command as root
:
docker run image_name container-usage
To launch an interactive shell within a docker-formatted container image you built, run the following command as root
:
docker run -ti image_name /bin/bash -l
In both of the above commands, substitute the image_name parameter with the name of the container image you chose when building it.
Example 10.3. Using elfutils in a Custom-Built Red Hat Developer Toolset Image
This example illustrates how to launch a custom-built docker-formatted container image with the elfutils component and how to run the eu-size
tool within that image.
To launch the container image with an interactive shell, issue the following command:
# docker run -ti devtoolset-6-my-perftools /bin/bash -l
To launch the container as a regular (non-root) user, use the
sudo
command. To map a directory from the host system to the container file system, include the-v
(or--volume
) option in thedocker
command:$
sudo docker run -v ~/Source:/src -ti devtoolset-6-my-perftools /bin/bash -l
In the above command, the host’s
~/Source/
directory is mounted as the/src/
directory within the container.Once you are in the container’s interactive shell, you can run Red Hat Developer Toolset tools as expected. For example, to verify the version of the
eu-size
tool, run:bash-4.2$
eu-size -V
size (elfutils) 0.168 [...]
10.3. Red Hat Developer Toolset Toolchain
10.3.1. Description
The Red Hat Developer Toolset Toolchain images provide the GNU Compiler Collection (GCC) and GNU Debugger (GDB).
The rhscl/devtoolset-6-toolchain-rhel7 image provides content corresponding to the following packages:
Component | Version | Package |
---|---|---|
| 6.3.1 | devtoolset-6-gcc |
| devtoolset-6-gcc-c++ | |
| devtoolset-6-gcc-fortran | |
| 7.12.1 | devtoolset-6-gdb |
The rhscl/devtoolset-4-toolchain-rhel7 image provides content corresponding to the following packages:
Component | Version | Package |
---|---|---|
| 5.3.1 | devtoolset-4-gcc |
| devtoolset-4-gcc-c++ | |
| devtoolset-4-gcc-fortran | |
| 7.11 | devtoolset-4-gdb |
10.3.2. Access
To pull the rhscl/devtoolset-6-toolchain-rhel7 image, run the following command as root:
# docker pull registry.access.redhat.com/rhscl/devtoolset-6-toolchain-rhel7
To pull the rhscl/devtoolset-4-toolchain-rhel7 image, run the following command as root:
# docker pull registry.access.redhat.com/rhscl/devtoolset-4-toolchain-rhel7
10.4. Red Hat Developer Toolset Performance Tools
10.4.1. Description
The Red Hat Developer Toolset Performance Tools images provide a number of profiling and performance measurement tools.
The rhscl/devtoolset-6-perftools-rhel7 image provides the following components:
Component | Version | Package |
---|---|---|
| 1.1.0 | devtoolset-6-oprofile |
| 3.0 | devtoolset-6-systemtap |
| 3.12.0 | devtoolset-6-valgrind |
| 9.2.0 | devtoolset-6-dyninst |
| 0.168 | devtoolset-6-elfutils |
The rhscl/devtoolset-4-perftools-rhel7 image provides the following components:
Component | Version | Package |
---|---|---|
| 1.1.0 | devtoolset-4-oprofile |
| 2.9 | devtoolset-4-systemtap |
| 3.11.0 | devtoolset-4-valgrind |
| 9.1.0 | devtoolset-4-dyninst |
| 0.166 | devtoolset-4-elfutils |
10.4.2. Access
To pull the rhscl/devtoolset-6-perftools-rhel7 image, run the following command as root:
# docker pull registry.access.redhat.com/rhscl/devtoolset-6-perftools-rhel7
To pull the rhscl/devtoolset-4-perftools-rhel7 image, run the following command as root:
# docker pull registry.access.redhat.com/rhscl/devtoolset-4-perftools-rhel7
10.4.3. Usage
Using the SystemTap Tool from Container Images
When using the SystemTap tool from a container image, additional configuration is required, and the container needs to be run with special command-line options.
The following three conditions need to be met:
The image needs to be run with super-user privileges. To do this, run the image using the following command:
~]$
docker run --ti --privileged --ipc=host --net=host --pid=host devtoolset-6-my-perftools /bin/bash -l
To use the pre-built perftools image, substitute the image name for devtoolset-6-perftools-rhel7 in the above command.
The following kernel packages need to be installed in the container:
- kernel
- kernel-devel
kernel-debuginfo
The version and release numbers of the above packages must match the version and release numbers of the kernel running on the host system. Run the following command to determine the version and release numbers of the hosts system’s kernel:
~]$ uname -r 3.10.0-514.10.2.el7.x86_64
Note that the kernel-debuginfo package is only available from the Debug channel. Enable the
rhel-7-server-debug-rpms
repository as described in TODO WHERE. For more information on how to get access to debuginfo packages, see https://access.redhat.com/site/solutions/9907.To install the required packages with the correct version, use the yum package manager and the output of the
uname
command. For example, to install the correct version of the kernel package, run the following command asroot
:~]# yum install -y kernel-$(uname -r)
Save the container to a reusable image by executing the
docker commit
command. To save a custom-built SystemTap container:~]$
docker commit devtoolset-6-systemtap-$(uname -r)