gpt4 book ai didi

docker - 如何在docker centos7中安装gcc7

转载 作者:行者123 更新时间:2023-12-02 18:46:08 24 4
gpt4 key购买 nike

我正在尝试基于centos7构建docker镜像

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

最佳答案

FROM centos:centos7
RUN yum update -y
RUN yum groupinstall "Development Tools" -y
RUN yum install wget -y
RUN curl -O https://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
RUN tar xzf gcc-7.3.0.tar.gz
RUN cd gcc-7.3.0
RUN ./contrib/download_prerequisites
RUN cd ..
RUN mkdir gcc-build
RUN cd gcc-build
RUN ../gcc-7.3.0/configure \
--enable-shared \
--enable-threads=posix \
--enable-__cxa_atexit \
--enable-clocale=gnu \
--disable-multilib \
--enable-languages=all
RUN make
# (Go make a cup of ice tea :)
RUN make install

为了节省构建时间,您可以使用“docker commit”从运行的docker创建一个新的docker,或者将/ usr / local保存到tar文件,然后在其他任何新的centos7 docker上打开它。

关于docker - 如何在docker centos7中安装gcc7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55901985/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com