docker - 如何在docker centos7中安装gcc7
问题描述
我正在尝试基于centos7
FROM centos:centos7
RUN yum -y update
RUN yum -y install gcc
RUN gcc --version
安装gcc
的是4.8:
步
4/4 : RUN gcc --version
---> Running in 70b9aa4a1f67
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
如何安装 gcc7?我试过 devtools-7,它不起作用:
FROM centos:centos7
RUN yum -y update
RUN yum -y install scl-utils
RUN yum -y install devtoolset-7-gcc
RUN scl enable devtoolset-7 bash
RUN gcc --version
我有:
Step 4/6 : RUN yum -y install devtoolset-7-gcc
---> Running in 85b49f411d4c
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirror.imt-systems.com
* extras: mirror.23media.com
* updates: ftp.plusline.net
No package devtoolset-7-gcc available.
Error: Nothing to do
The command '/bin/sh -c yum -y install devtoolset-7-gcc' returned a non-zero code: 1
解决方案
Dockerfile 中的以下命令对我有用:
RUN yum install -y centos-release-scl
RUN yum install -y devtoolset-7-gcc-*
RUN echo "source scl_source enable devtoolset-7" >> /etc/bashrc
RUN source /etc/bashrc
推荐阅读
- php - 如何根据php中的多个下拉选择获取表中的选定值
- javascript - 如何在 VueJS 的方法中访问表单变量
- javascript - 我该如何解决这个问题:Uncaught SyntaxError: missing ) after argument list
- gcc - 构建带有错误的 GCC 4.4.7(一些警告被视为错误)
- css - 盒子阴影动画是改变大小
- android - 如何使用改造 + 协程处理错误响应
- reactjs - Next js:在后退按钮上单击页面内容未加载
- c - msys2 如何显示非控制台应用程序的控制台输出?
- dart - 如何在 Flutter 中显示 onclick 按钮动画布局?
- arangodb - ArangoDB AQL:在不使用 startVertex 的情况下遍历所有图边