一、预备命令:
1、缺少find命令,使用: sudo yum install findutils
2、缺少string命令, 使用: sudo yum install binutils
3、缺少ifconfig ,yum安装ifconfig这个命令包。命令:yum search ifconfig 。 使用: sudo yum install net-tools
4、 查看gcc的编译参数:
echo | gcc -v -x c -E -
5、docker清理命令:
docker ps -a |grep Exited|awk '{print "docker rm "$1}'|sh
docker images|grep none |awk '{print "docker rmi "$3}'|sh
docker save -o images.tar postgres:9.6 mongo:3.4
docker load -i images.tar
二、执行以下命令检查动态库:
# 运行daocker容器
docker run -it euleros:2.0.5 /bin/bash
# 执行以下命令检查动态库
yum install -y binutils
strings /usr/lib64/libstdc++.so.6 | grep GLIBC
find / -name "libstdc++*"
三、预安装的开发库
# 安装开发工具
yum -y install wget gcc make bzip2
yum clean all && yum makecache && rpm -rebuilddb
yum install -y uuid
yum install -y libffi-devel
yum makecache && rpm -rebuilddb
yum install -y cmake3 gcc gcc-c++ make curl git unzip automake libtool rpmbuild
# python 编译安装部件
yum -y install zlib openssl ncurses sqlite readline tk gdbm db4 libpcap xz libffi expat uuid libuuid
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel
yum -y install tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum -y install kernel-devel kenel-headers libffi-devel
yum -y install expat-devel e2fsprogs-devel uuid-devel libuuid-devel tcl
yum -y install gdbm-devel tcl-devel python-tools
四、下载:
# 设置代理,如果不需要,可以不执行该步骤
export http_proxy=http://1.2.3.4:3128
export https_proxy=http://1.2.3.4:3128
Build_root_dir=/home/z00231941/tools
cd $Build_root_dir
wget http://mirrors.ustc.edu.cn/gnu/gmp/gmp-6.1.2.tar.xz
wget http://mirrors.ustc.edu.cn/gnu/mpfr/mpfr-4.0.2.tar.gz
wget http://mirrors.ustc.edu.cn/gnu/mpc/mpc-1.1.0.tar.gz
wget http://mirrors.ustc.edu.cn/gnu/m4/m4-1.4.18.tar.gz
wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.gz
五、dockerfile文件(euleros-gcc-prep.dockerfile):
构建命令:docker build -f euleros-gcc-prep.dockerfile -t euleros-gcc-prep:0.1.0 .
运行命令:docker run -it euleros-gcc-prep:0.1.0 /bin/bash
# Version 1.0.0
# build cmd: docker build -f euleros-gcc-prep.dockerfile -t euleros-gcc-prep:0.1.0 .
# docker run -it euleros-gcc-prep:0.1.0 /bin/bash
# docker ps -a |grep Exited|awk '{print "docker rm "$1}'|sh
# docker images|grep none |awk '{print "docker rmi "$3}'|sh
# 基础镜像
FROM euleros:2.0.5 as build0
# 维护者信息
MAINTAINER [email protected]
# 镜像操作命令
RUN yum clean all && yum makecache && rpm -rebuilddb && \
yum install -y cmake3 gcc gcc-c++ make curl git unzip automake libtool wget file
ENV SOFT_VERSION=make-4.2
RUN mkdir -p /my_build && cd /my_build && \
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gnu/make/$SOFT_VERSION.tar.gz && \
tar -zxvf $SOFT_VERSION.tar.gz && \
rm -fr $SOFT_VERSION.tar.gz && \
cd $SOFT_VERSION && \
./configure --prefix=/usr/local/$SOFT_VERSION && \
make && \
make install && \
ln -s /usr/local/$SOFT_VERSION/bin/make /usr/local/bin/make
ENV SOFT_VERSION=m4-1.4.18
RUN mkdir -p /my_build && cd /my_build && \
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gnu/m4/$SOFT_VERSION.tar.gz && \
tar -zxvf $SOFT_VERSION.tar.gz && \
rm -fr $SOFT_VERSION.tar.gz && \
cd $SOFT_VERSION && \
./configure --prefix=/usr/local/$SOFT_VERSION && \
make && \
make install && \
ln -s /usr/local/$SOFT_VERSION/bin/m4 /usr/local/bin/m4
ENV SOFT_VERSION=gmp-6.1.2
RUN mkdir -p /my_build && cd /my_build && \
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gnu/gmp/$SOFT_VERSION.tar.xz && \
tar -Jxvf $SOFT_VERSION.tar.xz && \
rm -fr $SOFT_VERSION.tar.xz && \
cd $SOFT_VERSION && \
./configure --prefix=/usr/local/$SOFT_VERSION && \
make && \
make install && \
ln -s /usr/local/$SOFT_VERSION /usr/local/gmp
ENV SOFT_VERSION=mpfr-4.0.2
RUN mkdir -p /my_build && cd /my_build && \
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gnu/mpfr/$SOFT_VERSION.tar.gz && \
tar -zxvf $SOFT_VERSION.tar.gz && \
rm -fr $SOFT_VERSION.tar.gz && \
cd $SOFT_VERSION && \
./configure --prefix=/usr/local/$SOFT_VERSION --with-gmp=/usr/local/gmp && \
make && \
make install && \
ln -s /usr/local/$SOFT_VERSION /usr/local/mpfr
ENV SOFT_VERSION=mpc-1.1.0
RUN mkdir -p /my_build && cd /my_build && \
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gnu/mpc/$SOFT_VERSION.tar.gz && \
tar -zxvf $SOFT_VERSION.tar.gz && \
rm -fr $SOFT_VERSION.tar.gz && \
cd $SOFT_VERSION && \
./configure --prefix=/usr/local/$SOFT_VERSION --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr && \
make && \
make install && \
ln -s /usr/local/$SOFT_VERSION /usr/local/mpc
RUN rm -fr /my_build && \
yum clean all && rm -fr /tmp/* && rm -fr /var/cache/*
FROM scratch
COPY --from=build0 / /
六、dockerfile文件(euleros-gcc-dev.dockerfile):
GCC重要版本: 4.8.5 4.9.4 5.5.0 6.5.0 8.2.0 8.3.0 9.1.0 9.2.0
构建命令:
export GCC_VERSION=4.9.4;docker build --build-arg GCC_VERSION=$GCC_VERSION -f euleros-gcc-dev.dockerfile -t euleros-gcc-dev:$GCC_VERSION .
export GCC_VERSION=5.5.0;docker build --build-arg GCC_VERSION=$GCC_VERSION -f euleros-gcc-dev.dockerfile -t euleros-gcc-dev:$GCC_VERSION .
export GCC_VERSION=8.2.0;docker build --build-arg GCC_VERSION=$GCC_VERSION -f euleros-gcc-dev.dockerfile -t euleros-gcc-dev:$GCC_VERSION .
export GCC_VERSION=9.2.0;docker build --build-arg GCC_VERSION=$GCC_VERSION -f euleros-gcc-dev.dockerfile -t euleros-gcc-dev:$GCC_VERSION .
运行命令:export GCC_VERSION=4.9.4 ; docker run -it euleros-gcc-dev:$GCC_VERSION /bin/bash
# Version 1.0.0
# gcc_version: 4.9.4 5.5.0 6.5.0 8.2.0 8.3.0 9.1.0 9.2.0
# build cmd: export GCC_VERSION=4.9.4 ; docker build --build-arg GCC_VERSION=$GCC_VERSION -f euleros-gcc-dev.dockerfile -t euleros-gcc-dev:$GCC_VERSION .
# run cmd: export GCC_VERSION=4.9.4 ; docker run -it euleros-gcc-dev:$GCC_VERSION /bin/bash
# docker ps -a |grep Exited|awk '{print "docker rm "$1}'|sh
# docker images|grep none |awk '{print "docker rmi "$3}'|sh
# 基础镜像
FROM euleros-gcc-prep:0.1.0 as build0
# 维护者信息
MAINTAINER [email protected]
ARG GCC_VERSION="4.9.4"
ENV GCC_VERSION=$GCC_VERSION
RUN yum clean all && yum makecache && rpm -rebuilddb && \
yum install -y zlib-devel
RUN mkdir -p /my_build && cd /my_build && \
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz && \
tar -zxvf gcc-$GCC_VERSION.tar.gz && \
rm -fr gcc-$GCC_VERSION.tar.gz && \
cd gcc-$GCC_VERSION && \
mkdir build && cd build && \
export LD_LIBRARY_PATH=`pwd`/prev-x86_64-Huawei-linux/libstdc++-v3/src/.libs/:/usr/local/gmp/lib:/usr/local/mpfr/lib:/usr/local/mpc/lib:$LD_LIBRARY_PATH && \
../configure --prefix=/usr/local/gcc-$GCC_VERSION --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc \
--enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu \
--enable-languages=c,c++ --enable-plugin --enable-initfini-array --disable-libgcj \
--enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --disable-multilib \
--with-stage1-ldflags=' -Wl,-z,relro,-z,now' --with-boot-ldflags=' -Wl,-z,relro,-z,now' \
--with-tune=generic --with-arch_32=x86-64 --build=x86_64-Huawei-linux && \
make && \
make install && \
ln -s /usr/local/gcc-$GCC_VERSION/bin/gcc /usr/local/bin/gcc && \
ln -s /usr/local/gcc-$GCC_VERSION/bin/g++ /usr/local/bin/g++ && \
ln -s /usr/local/gcc-$GCC_VERSION/bin/c++ /usr/local/bin/c++ && \
ln -s /usr/local/gcc-$GCC_VERSION/bin/cpp /usr/local/bin/cpp
RUN rm -fr /my_build && \
yum clean all && rm -fr /tmp/* && rm -fr /var/cache/*
FROM scratch
COPY --from=build0 / /
七、参考资料:
参考资料:http://m.blog.chinaunix.net/uid-20682147-id-5820902.html#_Toc17085