centos7 Dockerfile install nginx

1. Write a Dockerfile

FROM centos
MAINTAINER apeng [email protected]
RUN yum install -y pcre-devel wget net-tools gcc zlib zlib-devel make openssl-devel
ADD http://nginx.org/download/nginx-1.8.0.tar.gz .
RUN tar zxvf nginx-1.8.0.tar.gz
RUN mkdir -p /usr/local/nginx
RUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make -j 4 && make -j 4  install
RUN rm -fv /usr/local/nginx/conf/nginx.conf
ADD http://www.apelearn.com/study_v2/.nginx_conf  /usr/local/nginx/conf/nginx.conf
EXPOSE 80
ENTRYPOINT /usr/local/nginx/sbin/nginx && tail -f /etc/passwd

2. Create new images as centos:nginx

[root@localhost nginx]# docker build -t centos:nginx .

3. View the mirror

[root@localhost mail]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
centos              nginx               f9969a963007        About a minute ago   372MB
lz/centos           6.7                 88b1501bda70        About an hour ago    191MB

4. Map container ports

[root@localhost ~]# docker run -itd -p 80:80 centos:nginx /bin/bash
f52eac063359bfbe8273f8b8bd8965d9325887d020a6d8f0e4314d2e2a2120d7
[root@localhost ~]#

5. Access in the browser

As shown in the figure, the installation is successful!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324679271&siteId=291194637