Dokcer製作nginx映象,提交映象至倉庫

YatHo發表於2017-11-15

生成Dockerfile

FROM docker.io/hagaico/centos-base-6.5:latest

MAINTAINER yatho yatho@163.com

ENV DEBIAN_FRONTEND noninteractive

WORKDIR /usr/local/src

RUN yum -y update && \
	yum install -y wget gcc make pcre-devel autoconf automake zlib zlib-devel openssl openssl-devel  gcc gcc-c++ glibc glibc-common telnet tcl dos2unix sysstat make openssh-clients  unzip && \
	wget http://nginx.org/download/nginx-1.12.2.tar.gz && \
	wget ftp://ftp.openssl.org/source/old/1.0.2/openssl-1.0.2k.tar.gz

ADD ./pcre-8.41.tar.gz /usr/local/src/
ADD ./libssl.so.1.0.1e /lib64/

RUN tar -zxvf nginx-1.12.2.tar.gz && \
	tar -zxvf openssl-1.0.2k.tar.gz -C /usr/local/src
	
WORKDIR /usr/local/src/nginx-1.12.2

RUN ./configure   --prefix=/usr/local/nginx   --with-pcre=/usr/local/src/pcre-8.41 --with-http_stub_status_module --with-stream  --with-http_ssl_module --with-http_realip_module --with-openssl=/usr/local/src/openssl-1.0.2k && \
	make && \
	make install && \
	echo "daemon off;">>/usr/local/nginx/conf/nginx.conf
	
ADD run.sh /usr/local/sbin/run.sh
RUN chmod 755 /usr/local/sbin/run.sh

CMD ["/usr/local/sbin/run.sh"]

EXPOSE 22
EXPOSE 80
EXPOSE 443

  生成run.sh指令碼

#!/bin/bash
/usr/sbin/sshd &
/usr/local/nginx/sbin/nginx

  目錄結構

  

[root@vm-50-151 nginx]# pwd
/root/docker/Docker_file/nginx
[root@vm-50-151 nginx]# ll
total 8620
-rw-r--r-- 1 root root    1160 Nov 15 13:43 Dockerfile
-rw-r--r-- 1 root root  449808 Nov 15 11:01 libssl.so.1.0.1e
-rw-r--r-- 1 root root  981687 Nov 15 11:01 nginx-1.12.2.tar.gz
-rw-r--r-- 1 root root 5309236 Nov 15 11:01 openssl-1.0.2k.tar.gz
-rw-r--r-- 1 root root 2068775 Nov 15 11:01 pcre-8.41.tar.gz
-rw-r--r-- 1 root root      57 Nov 15 11:01 run.sh

  構建生成映象

[root@vm-50-151 nginx]# docker build -t yatho_nginx:1.0.0 .

  啟動映象測試映象是否OK

[root@vm-50-151 nginx]# docker run -d --name nginx_test -P yatho_nginx:1.0.0

  

[root@vm-50-151 nginx]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                  NAMES
14330de27f9d        yatho_nginx:1.0.1   "/usr/local/sbin/run."   40 minutes ago      Up 40 minutes       0.0.0.0:32770->22/tcp, 0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp   nginx_test

 

  給映象打tag

[root@vm-50-151 nginx]# docker tag yatho_nginx:1.0.0 yatho92/yatho_nginx_centos6.5:1.0.0

  提交至倉庫

[root@vm-50-151 nginx]# docker push yatho92/yatho_nginx_centos6.5:1.0.0

  

相關文章