我想按照本教程在容器(CentOS 6.9)中将 GCC 从 4.4.7 更新到 4.7.2如何在 CentOS 上升级 GCC http://ask.xmodulo.com/upgrade-gcc-centos.html.
在教程的最后,作者使用scl enable devtoolset-1.1 bash
启动一个新的 shell,其中所有环境都已更新。我编写了以下 Dockerfile:
Run ... \
&& yum install devtoolset-1.1 \
&& scl enable devtoolset-1.1 bash
然而,当我从Dockerfile生成的镜像运行容器时,我发现GCC版本仍然是4.4.7,这表明我进入了旧的shell。
虽然我通过显式定义 CC、CPP、CXX 变量成功更新了容器中的 GCC,但我仍然想知道如何在 Dockerfile 中使用“scl”命令更新 GCC。也就是说,如何在Dockerfile中输入一个新的shell呢?
先感谢您。 ^_^
为了扩展@user2915097的答案,这里有一个使用的工作示例devtoolset-7
and rh-python36
代替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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)