1.从centos构建镜像mkdir/mnt/nginxvim docker file:7运行yum install -y gcc pcrepcr -devel devel zlib -devel make add nginx -1 . 22 . 0 . tar . gz/mnt/ngxwork dir/MNT/nginx/nginx -1 . 22 . 0 #关闭调试日志runsed -I ' s/cflags = " $ cflags -g "/# cflags = " $ cflags -g "/g ' auto/cc/gcc run。/configure 4 usr/local/nginx RUN make RUN make install expose 80 volume
二、不需要输出的指令从centos扔进/dev/null:7运行yum install -y gcc pcre -devel devel zlib -devel make & >/dev/null & amp;& ampyum clean all add nginx -1 . 22 . 0 . tar . gz/mnt/nginxWORKDIR/mnt/nginx/nginx -1 . 22 . 0 run sed -I ' s/CFLAGS = " $ CFLAGS -g "/# CFLAGS = " $ CFLAGS -g "/g ' auto/cc/gcr un。/configure --prefix =/usr/local/nginx & amp;& gt/dev/null run make & amp;& gt/dev/nullRUN进行安装。& gt/dev/null run RM -RF/mnt/nginx/nginx -1 . 22 . 0 expose 80 volume
三。减少从centos运行和构建:7 add nginx -1 . 22 . 0 . tar . gz/mnt/nginxworkdir/mnt/nginx/nginx -1 . 22 . 0 RUN yum install -y gcc pcrepcr -devel devel zlib -devel make & >/dev/null & amp;& amp\ yum clean all & amp& amp\ sed -I ' s/CFLAGS = " $ CFLAGS -g "/# CFLAGS = " $ CFLAGS -g "/g ' auto/cc/gcc & amp;& amp\ ./configure --prefix =/usr/local/nginx & amp;& gt/dev/null & amp;& amp制造& amp& gt/dev/null & amp;& amp制作安装& amp& gt/dev/null & amp;& amp\ RM -RF/mnt/nginx/nginx -1 . 22 . 0曝光80卷
Docker build -t nginx:v3。建立形象
Docker图像观察镜
四。从Centos多级构建:7 as build add nginx -1 . 22 . 0 . tar . gz/mnt/nginxworkdir/mnt/nginx/nginx -1 . 22 . 0 run yum install -y gcc pcrepcr -devel devel zlib -devel make & >/dev/null & amp;& amp\ yum clean all & amp& amp\ sed -I ' s/CFLAGS = " $ CFLAGS -g "/# CFLAGS = " $ CFLAGS -g "/g ' auto/cc/gcc & amp;& amp\./configure --prefix =/usr/local/nginx & amp;& gt/dev/null & amp;& amp制造& amp& gt/dev/null & amp;& amp\进行安装& amp& gt/dev/null & amp;& amp\ RM -RF/mnt/nginx/nginx -1 . 22 . 0 from centos:7 expose 80卷
5.使用更轻便的linux发行版Debian Alpineapt Addsandboxbusybox。
#下载debian压缩包WGET http://Download . openvz . org/template/pre created/Debian -7.0-x86-minimal . tar . gz docker导入Debian -7.0-x86-minimal . tar . gz --Debian:v1生成图像docker图像视图
综上所述,dockerfile高级教程中关于dockerfile优化图像大小的这篇文章就介绍到这里了。关于Dockerfile优化图片尺寸的更多信息,请搜索主机频道zhujipindao的往期文章。或者继续浏览下面的相关文章。希望大家支持主机频道zhujipindao。以后多来com!
评论前必须登录!
注册