使用docker创建C++编译环境,自动创建二进制执行程序。
docker run 一次执行多条命令的方法 有时在启动docker container时需要同时运行不止一条命令,这时在command处使用:sh -c ‘ cmd1 && cmd2 ‘即可。
如,docker run -it myimage sh -c ‘service mysql start && python test.py’
编译 acl rpm 包 方法一: 创建 acl 编译镜像 编写 Dokcerfile 1 2 FROM centos:6.10RUN yum -y install gcc gcc-c++ zlib-devel git rpm-build
创建镜像 1 docker build -t rpm-build-image .
创建容器编译 1 2 3 4 5 git clone https://gi tee.com/acl-dev/ acl.git docker run --rm -v "$(pwd)" :/usr/ app/ -w /u sr/app/ acl/packaging rpm-build-image make
or
1 2 3 4 5 docker run --rm -v "$(pwd)" :/usr/app/ -w /usr/app rpm-build-image sh -c 'git clone https://gitee.com/acl-dev/acl.git && cd acl/packaging && make ' docker run --rm -v "$(pwd)" :/usr/app/ rpm-build-image sh -c 'git clone https://gitee.com/acl-dev/acl.git && cd acl/packaging && make && mv x86_64 /usr/app'
方法二: 不创建镜像,直接使用临时容器 1 2 3 4 5 docker run --rm -v "$(pwd)" :/usr/app / centos:6.10 su -c 'yum -y install gcc gcc-c++ zlib-devel git rpm-build \ && git clone https: && cd acl/packaging \ && make \ && mv x86_64 /usr/app '
CentOS nginx 添加 ngx_http_proxy_connect_module 1 docker run -it --rm -v "$(pwd)" :/usr/ app/nginx -w /u sr/app/ nginx centos:7.9 .2009 bash -c '/usr/app/nginx/build-env.sh'
build-env.sh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #!/bin/bash yum -y update yum -y install gcc gcc-c++ automake autoconf libtool make rpm-build rpmdevtools rpmlint wget git yum -y install -y openssl openssl-devel zlib-devel pcre-devel gd-devel name=rpmbuild useradd $name echo "$name ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoerssu - $name -c '/usr/app/nginx/build.sh'
build.sh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #!/bin/bash rpmdev-setuptree cd ~/rpmbuild/SOURCESwget http://nginx.org/packages/centos/7/SRPMS/nginx-1.18.0-2.el7.ngx.src.rpm rpm2cpio nginx-1.18.0-2.el7.ngx.src.rpm |cpio -dvi git clone https://github.com/chobits/ngx_http_proxy_connect_module.git tar xfz nginx-1.18.0.tar.gz cd nginx-1.18.0patch -p1 < ../ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_1018.patch cd ..tar cfz nginx-1.18.0.tar.gz nginx-1.18.0 rm -r nginx-1.18.0sed -i '/configure %{BASE_CONFIGURE_ARGS}/a\ --add-module=/home/rpmbuild/rpmbuild/SOURCES/ngx_http_proxy_connect_module \\' nginx.spec rpmbuild -bb nginx.spec cp ../RPMS/x86_64/* /usr/app/nginx