Docker 构建找不到 G++,手动 运行 该步骤有效
Docker build fails to find G++, manually running the step works
我的镜像试图在 centos7 基础上从源代码构建 protobuf 3.9.1。更新和安装依赖项后,第一步是 运行 来自 protobuf 存储库的 ./configure
脚本。这通过并找到构建所需的一堆依赖项。
docker build
在 RUN ./configure
上失败,原因是 checking for g++... no
。当通过直接在失败步骤之前的层中执行 docker run
手动 运行ning 脚本时,./configure
能够找到 g++:checking for g++... g++
.
关于 docker build
和手动 运行 之间可能导致这种不同行为的任何建议?感谢阅读!
Docker 文件:
FROM centos:7
ENV PROJECTDIR=/src
RUN mkdir -p $PROJECTDIR
WORKDIR $PROJECTDIR
RUN yum -y update && yum clean all
RUN yum install -y epel-release centos-release-scl
RUN yum install -y cmake3 devtoolset-7-gcc* devtoolset-7-gdb* llvm-toolset-7-llvm-devel llvm-toolset-7-clang-devel llvm-toolset-7-lldb make boost169-devel boost169-static openssh-server rsync git ccache autoconf automake libtool unzip tree
RUN echo 'root:root' | chpasswd
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
RUN echo "path = /opt/rh/devtoolset-7/root/usr/bin:/opt/rh/llvm-toolset-7/root/usr/bin" > /etc/ccache.conf
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/c++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/g++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/x86_64-redhat-linux-c++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/x86_64-redhat-linux-g++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/clang
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/clang++
RUN /usr/sbin/sshd-keygen
# Protobuf C++ Install
RUN mkdir $PROJECTDIR/protobuf
ADD https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protobuf-cpp-3.9.1.tar.gz $PROJECTDIR/protobuf/protobuf-cpp-3.9.1.tar.gz
RUN tar -xf $PROJECTDIR/protobuf/protobuf-cpp-3.9.1.tar.gz -C $PROJECTDIR/protobuf/
WORKDIR $PROJECTDIR/protobuf/protobuf-3.9.1
RUN ./configure
make && \
make check && \
make install && \
ldconfig
RUN mkdir -p /root/.ssh
ENV PATH="$PROJECTDIR:${PATH}"
CMD bash
编辑:
我试过 docker 构建有无 cacche
没有影响
您缺少 GNU Compiler Collection,因此应将其作为依赖项安装。
If you are trying to build using make, ensure you've installed the gcc-g++
package! Without it, your build will fail in the way you are seeing.
在配置前安装gcc-c++
RUN yum install gcc-c++ -y
此外,更正您缺少的配置命令 && \
RUN yum install gcc-c++ -y
RUN ./configure && \
make && \
make check && \
make install && \
ldconfig
我的镜像试图在 centos7 基础上从源代码构建 protobuf 3.9.1。更新和安装依赖项后,第一步是 运行 来自 protobuf 存储库的 ./configure
脚本。这通过并找到构建所需的一堆依赖项。
docker build
在 RUN ./configure
上失败,原因是 checking for g++... no
。当通过直接在失败步骤之前的层中执行 docker run
手动 运行ning 脚本时,./configure
能够找到 g++:checking for g++... g++
.
关于 docker build
和手动 运行 之间可能导致这种不同行为的任何建议?感谢阅读!
Docker 文件:
FROM centos:7
ENV PROJECTDIR=/src
RUN mkdir -p $PROJECTDIR
WORKDIR $PROJECTDIR
RUN yum -y update && yum clean all
RUN yum install -y epel-release centos-release-scl
RUN yum install -y cmake3 devtoolset-7-gcc* devtoolset-7-gdb* llvm-toolset-7-llvm-devel llvm-toolset-7-clang-devel llvm-toolset-7-lldb make boost169-devel boost169-static openssh-server rsync git ccache autoconf automake libtool unzip tree
RUN echo 'root:root' | chpasswd
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
RUN echo "path = /opt/rh/devtoolset-7/root/usr/bin:/opt/rh/llvm-toolset-7/root/usr/bin" > /etc/ccache.conf
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/c++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/g++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/x86_64-redhat-linux-c++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/x86_64-redhat-linux-g++
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/clang
RUN ln -sf ../../bin/ccache /usr/lib64/ccache/clang++
RUN /usr/sbin/sshd-keygen
# Protobuf C++ Install
RUN mkdir $PROJECTDIR/protobuf
ADD https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protobuf-cpp-3.9.1.tar.gz $PROJECTDIR/protobuf/protobuf-cpp-3.9.1.tar.gz
RUN tar -xf $PROJECTDIR/protobuf/protobuf-cpp-3.9.1.tar.gz -C $PROJECTDIR/protobuf/
WORKDIR $PROJECTDIR/protobuf/protobuf-3.9.1
RUN ./configure
make && \
make check && \
make install && \
ldconfig
RUN mkdir -p /root/.ssh
ENV PATH="$PROJECTDIR:${PATH}"
CMD bash
编辑:
我试过 docker 构建有无 cacche
没有影响
您缺少 GNU Compiler Collection,因此应将其作为依赖项安装。
If you are trying to build using make, ensure you've installed the gcc-g++ package! Without it, your build will fail in the way you are seeing.
在配置前安装gcc-c++
RUN yum install gcc-c++ -y
此外,更正您缺少的配置命令 && \
RUN yum install gcc-c++ -y
RUN ./configure && \
make && \
make check && \
make install && \
ldconfig