1, download mirror
First of all, we need a system to take the official CentOS as an example, first pull down
[Root@zabbix-3 ~]# Docker Pull CentOS
Using default Tag:latest
Latest:pulling from Library/centos
A3ed95caeb02:already exists
A3ed95caeb02:already exists
digest:sha256:1a62cd7c773dd5c6cf08e2e28596f6fcc99bd97e38c9b324163e0da90ed27562
Status:image is up to date for centos:latest
[Root@zabbix-3 ~]#
2, in the boot container, to compile the installation
[Root@zabbix-3 ~]# Docker run--name nginx-create-it CentOS
[Root@e0d020800f10/]#
Installing common packages and dependency packs in containers
[Root@e0d020800f10/]# yum install wget gcc gcc-c++ make openssl-devel-y
[Root@e0d020800f10/]# wget-p/usr/local/src/http://nginx.org/download/nginx-1.10.1.tar.gz
[Root@e0d020800f10/]# wget-p/usr/local/src/http://tenet.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
[Root@e0d020800f10 src]# cd/usr/local/src/
[Root@e0d020800f10 src]# Tar XF nginx-1.10.1.tar.gz
[Root@e0d020800f10 src]# Tar XF pcre-8.39.tar.gz
[Root@e0d020800f10 src]# useradd-s/sbin/nologin-m nginx
[Root@e0d020800f10 src]# CD nginx-1.10.1
[Root@e0d020800f10 nginx-1.10.1]#./configure \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--user=nginx \
--group=nginx \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-pcre=/usr/local/src/pcre-8.39
[Root@e0d020800f10 nginx-1.10.1]# make && make install
[Root@e0d020800f10 nginx-1.10.1]# sed-i ' 2 i\daemon off; '/etc/nginx/nginx.conf
3, Commit Commit
Then exit, commit commits, multiple commit commits name cannot be consistent
[Root@zabbix-3 ~]# Docker commit-m "v3" a1359ffc377f mark/nginx:v3
Sha256:18b54107232173c19e827005ccf2582b10ff316c224e6c6899ecc9ed19afc0c0
4, Submit complete view
[Root@zabbix-3 ~]# Docker Images
REPOSITORY TAG IMAGE ID CREATED SIZE
Mark/nginx v3 57289bc1d1f0 3 minutes ago 401.6 MB
Mark/nginx v2 b20b274f88ee 4 minutes ago 401.6 MB
Mark/nginx v1 18b541072321 about an hour ago 401.6 MB
REGISTRY.DS.COM/ZABBIX-3.0-XXL latest 59ac231a6d23 7 days ago 745.4 MB
CentOS latest 904d6c400333 3 weeks ago 196.7 MB
Registry.ds.com/centos latest 904d6c400333 3 weeks ago 196.7 MB
Nginx latest 0d409d33b27e 3 weeks ago 182.7 MB
Registry.ds.com/nginx latest 0d409d33b27e 3 weeks ago 182.7 MB
[Root@zabbix-3 ~]#
5, start
The port can be mapped to start when the commit is complete and appears in images
[Root@zabbix-3 ~]# Docker run-d-P 100:80 Mark/nginx:v3/usr/local/nginx/sbin/nginx
59e7cc86f4815245ff8b97962d600a2008910b36795a374704ce547bfd79671d
[Root@zabbix-3 ~]# Docker Ps-l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
da346dfe0477 mark/nginx:v3 "/usr/local/nginx/sbi" 4 minutes ago up 4 minutes 0.0.0.0:100->8 0/tcp Big_khorana
[Root@zabbix-3 ~]#