CentOS7.x 支持的 gcc 和 g++ 版本太低,使用 CentOS 8.x 进行替换,但在实际操作的过程中,使用yum进行依赖更新,出现报错,写此文以记录。
FROM centos:8.4.2105
RUN set -eux; \
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*; \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*; \
yum clean all; \
yum makecache; \
yum -y install gcc \
gcc-c++ \
gdb \
make \
cmake; \
yum clean all; \
yum makecache
COPY [ "ninja", "/usr/local/bin" ]
FROM scratch
COPY --from=0 / /
ENV ENV TZ="Asia/Shanghai" \
LANG="zh_CN.UTF-8"
CMD [ "/bin/bash" ]
顺便把 openEuler 的 C++ 构建镜像的 Dockerfile 也写一下:
FROM openeuler:20.03
RUN set -eux; \
yum -y install bc \
gcc \
gcc-c++ \
gdb \
make \
cmake; \
yum clean all; \
yum makecache
FROM scratch
COPY --from=0 / /
ENV ENV TZ="Asia/Shanghai" \
LANG="zh_CN.UTF-8"
CMD [ "/bin/bash" ]
|