1.8. Using Red Hat Developer Toolset Container Images
Note
1.8.1. Using Pre-Built Container Images
registry.access.redhat.com:
- rhscl/devtoolset-4-toolchain-rhel7The image contains the following Red Hat Developer Toolset components:
- devtoolset-4-gcc
- devtoolset-4-gcc-c++
- devtoolset-4-gcc-fortran
- devtoolset-4-gdb
- rhscl/devtoolset-4-perftools-rhel7The image contains all Red Hat Developer Toolset components included in the devtoolset-4-perftools metapackage:
- devtoolset-4-oprofile
- devtoolset-4-systemtap
- devtoolset-4-valgrind
- devtoolset-4-dyninst
1.8.1.1. Pulling Pre-Built Container Images from the Registry
root:
docker pull image_nameroot:
~]#docker pull rhscl/devtoolset-4-toolchain-rhel7
1.8.1.2. Running Red Hat Developer Toolset Tools from Pre-Built Container Images
root:
docker run image_name usageroot:
docker run -ti image_name /bin/bash -lroot:
~]#docker run -ti rhscl/devtoolset-4-toolchain-rhel7 /bin/bash -l
Example 1.1. Using GCC in the Pre-Built Red Hat Developer Toolset Toolchain Image
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-4-toolchain-rhel7 - To launch the container image with an interactive shell, issue the following command:
~]#docker run -ti rhscl/devtoolset-4-toolchain-rhel7 /bin/bash -l - To launch the container as a regular (non-root) user, use the
sudocommand. To map a directory from the host system to the container file system, include the-v(or--volume) option in thedockercommand:~]$sudo docker run -v ~/Source:/src -ti rhscl/devtoolset-4-toolchain-rhel7 /bin/bash -lIn 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
gcccompiler, run:bash-4.2$gcc -v[...] gcc version 5.2.1 20150716 (Red Hat 5.2.1-1) (GCC)
1.8.2. Using Container Images Built from Dockerfiles
- devtoolset-4-dyninst
- devtoolset-4-elfutils
- devtoolset-4-oprofile
- devtoolset-4-systemtap
- devtoolset-4-toolchain
- devtoolset-4-valgrind
- devtoolset-4
1.8.2.1. Obtaining Dockerfiles
~]#yum install devtoolset-4-dockerfiles
1.8.2.2. Building Container Images
root:
docker build -t image_nameExample 1.2. Building a Container Image with a Red Hat Developer Toolset Component
- 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-4-dockerfiles - Determine where the Dockerfile for the required component is located:
~]#rpm -ql devtoolset-4-dockerfiles | grep "elfutils/Dockerfile"/opt/rh/devtoolset-4/root/usr/share/devtoolset-4-dockerfiles/rhel7/devtoolset-4-elfutils/Dockerfile - Change to the directory where the required Dockerfile is installed:
~]#cd /opt/rh/devtoolset-4/root/usr/share/devtoolset-4-dockerfiles/rhel7/devtoolset-4-elfutils/ - Build the container image:
~]#docker build -t devtoolset-4-elfutils-7 .Replace devtoolset-4-elfutils-7 with the name you wish to assign to your resulting container image.
1.8.2.3. Running Red Hat Developer Toolset Tools from Custom-Built Container Images
root:
docker run image_name container-usageroot:
docker run -ti image_name /bin/bash -lExample 1.3. Using elfutils in a Custom-Built Red Hat Developer Toolset Image
eu-size tool within that image.
- To launch the container image with an interactive shell, issue the following command:
~]#docker run -ti devtoolset-4-elfutils-7 /bin/bash -l - To launch the container as a regular (non-root) user, use the
sudocommand. To map a directory from the host system to the container file system, include the-v(or--volume) option in thedockercommand:~]$sudo docker run -v ~/Source:/src -ti devtoolset-4-elfutils-7 /bin/bash -lIn 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-sizetool, run:bash-4.2$eu-size -Vsize (elfutils) 0.163 [...]
Using the SystemTap Tool from Container Images
- 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-4-systemtap /bin/bash -lThe above command assumes that you named the image devtoolset-4-systemtap when you built it from the Dockerfile (/opt/rh/devtoolset-4/root/usr/share/devtoolset-4-dockerfiles/rhel7/devtoolset-4-systemtap/Dockerfile).To use the perftools image, substitute the image name for devtoolset-4-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 -r3.10.0-229.14.1.el7.x86_64Note that the kernel-debuginfo package is only available from the Debug channel. Enable therhel-7-server-debug-rpmsrepository as described in Section 1.4.1, “Using Red Hat Subscription Management”. 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 theunamecommand. 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 commitcommand. For example, to save the custom-built SystemTap container:~]$docker commit devtoolset-4-systemtap-$(uname -r)

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.