Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在docker centos7中安装gcc7_Docker_Gcc_Centos7 - Fatal编程技术网

如何在docker centos7中安装gcc7

如何在docker centos7中安装gcc7,docker,gcc,centos7,Docker,Gcc,Centos7,我正在尝试建立一个基于centos7的docker形象 已安装的gcc为4.8: 台阶 如何安装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 : RU

我正在尝试建立一个基于centos7的docker形象

已安装的gcc为4.8:

台阶

如何安装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

显然,您当前的存储库配置中不存在devtoolset-7-gcc。尝试添加一个具有它的repo,或者尝试使用yum-y install centos release scl而不是yum-y install scl utils

在这里找到它:

玩得开心

编辑:

经过进一步的研究,似乎GCC7已经安装,但scl enable实际上正在打开一个新的bash,其中将包含您的GCC7。如果您真的需要将GCC7作为默认GCC,那么可以从源代码处编译它,但这需要很长时间,或者您可以使用dockerfile中的SHELL命令在SHELL之间进行替换。这是我的docker文件:

FROM centos:centos7

RUN yum -y update
RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-7-gcc*
SHELL [ "/usr/bin/scl", "enable", "devtoolset-7"]
RUN gcc --version
以及运行gcc-version的输出

在使用devtoolset时,在shell之间切换似乎是一种理想的方法,因为它允许您在需要时快速切换版本。
我希望这有帮助

显然,您当前的存储库配置中不存在devtoolset-7-gcc。尝试添加一个具有它的repo,或者尝试使用yum-y install centos release scl而不是yum-y install scl utils

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
在这里找到它:

玩得开心

编辑:

经过进一步的研究,似乎GCC7已经安装,但scl enable实际上正在打开一个新的bash,其中将包含您的GCC7。如果您真的需要将GCC7作为默认GCC,那么可以从源代码处编译它,但这需要很长时间,或者您可以使用dockerfile中的SHELL命令在SHELL之间进行替换。这是我的docker文件:

FROM centos:centos7

RUN yum -y update
RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-7-gcc*
SHELL [ "/usr/bin/scl", "enable", "devtoolset-7"]
RUN gcc --version
以及运行gcc-version的输出

在使用devtoolset时,在shell之间切换似乎是一种理想的方法,因为它允许您在需要时快速切换版本。 我希望这有帮助

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 commit从正在运行的docker创建一个新的docker,或将/usr/local保存到tar文件,并在任何其他新的centos7 docker上打开它。

docker文件中的以下命令对我有效:

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

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

简单地寻找个人资料是行不通的。您需要使用bash-l运行脚本。例如:

docker run-rm[你的IMG]bash-l[你的脚本]
然后新版本的GCC将被启用。

简单地寻找配置文件将不起作用。您需要使用bash-l运行脚本。例如:

docker run-rm[你的IMG]bash-l[你的脚本]
然后新版本的GCC将被启用。

不幸的是,它不起作用,我一直在获取GCC 4.8。您真的应该自己尝试一下,获取一个包含gcc7消息的工作dockerfile。我已经在谷歌上搜索了很长一段时间了,担心它不起作用:我会在有时间的时候亲自尝试。我用找到的一些解决方案编辑了我的回复。告诉我你对iTunes的看法幸运的是,它不起作用,我一直在得到GCC4.8,你真的应该试试自己,得到一个包含gcc7消息的工作文档。我已经在谷歌上搜索了很长一段时间了,担心它不起作用:我会在有时间的时候亲自尝试。我用找到的一些解决方案编辑了我的回复。告诉我你是怎么想的谢谢你的回答!它确实解决了这个问题,但是从源代码构建会使构建过程复杂且耗时,如果从预构建安装解决方案会更好。根据定义,预构建二进制文件是使用特定的libc构建的,因此每个CentOS版本将只有一个GCC预构建二进制文件版本,最新的操作系统将使用最新的GCC,而旧版本将使用旧的GCC,也许在CentOS7上构建GCC7源RPM就可以了。谢谢您的回答!它确实解决了这个问题,但是从源代码构建会使构建过程复杂且耗时,如果从预构建安装解决方案会更好。根据定义,预构建二进制文件是使用特定的libc构建的,因此每个CentOS版本将只有一个GCC预构建二进制文件版本,最新的操作系统将使用最新的GCC,而旧版本将使用旧的GCC,也许在CentOS7上构建GCC7源RPM就可以了。