I want to update GCC from 4.4.7 to 4.7.2 in a container(CentOS 6.9) following this tutorial How to upgrade GCC on CentOS.
In the end of the tutorial, the author uses <
Among the directives of the Dockerfile, you have SHELL
https://docs.docker.com/engine/reference/builder/#shell
from this doc
The SHELL instruction can also be used on Linux should an alternate shell be required such as zsh, csh, tcsh and others.
To expand on @user2915097's answer here is a working example using devtoolset-7
and rh-python36
instead of devtoolset-1.1
FROM centos:7
# Default version of GCC and Python
RUN gcc --version && python --version
# Install some developer style software collections with intent to
# use newer version of GCC and Python than the OS provided
RUN yum install -y centos-release-scl && yum install -y devtoolset-7 rh-python36
# Yum installed packages but the default OS-provided version is still used.
RUN gcc --version && python --version
# Okay, change our shell to specifically use our software collections.
# (default was SHELL [ "/bin/sh", "-c" ])
# https://docs.docker.com/engine/reference/builder/#shell
#
# See also `scl` man page for enabling multiple packages if desired:
# https://linux.die.net/man/1/scl
SHELL [ "/usr/bin/scl", "enable", "devtoolset-7", "rh-python36" ]
# Switching to a different shell has brought the new versions into scope.
RUN gcc --version && python --version