dockerfile 构建nginx镜像

bash 复制代码
root@aa:/opt#vim dockerfile-nginx
bash 复制代码
FROM centos:7.9.2009
MAINTAINER Bertrm<123@qq.com>

RUN buildDeps='readline-devel pcre-devel openssl-devel gcc telnet wget curl make' \
&& useradd -M -s /sbin/nologin nginx \
&& mkdir -p /usr/local/nginx/conf/vhost \
&& mkdir -p /data/logs/nginx \
&& yum -y install $buildDeps \
&& yum clean all \
&& wget http://nginx.org/download/nginx-1.14.2.tar.gz \
&& tar zxf nginx-1.14.2.tar.gz \
&& cd nginx-1.14.2 \
&& ./configure --prefix=/usr/local/nginx \
    --with-http_ssl_module \
    --with-http_stub_status_module \
&& make -j 1 && make install \
&& rm -rf /usr/local/nginx/html/* \
&& echo "hellow nginx is ok" >> /usr/local/nginx/html/index.html \
&& cd / && rm -rf nginx-1.14.2* \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENV PATH /usr/local/nginx/sbin:$PATH
WORKDIR /usr/local/nginx
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
bash 复制代码
docker build -f dockerfile-nginx  -t nginx:1.0 .
bash 复制代码
root@aa:/opt# docker images
REPOSITORY   TAG        IMAGE ID       CREATED          SIZE
nginx        1.0        d1b77a9a1d9e   21 minutes ago   318MB
centos       7.9.2009   eeb6ee3f44bd   12 months ago    204MB
root@aa:/opt# 
bash 复制代码
root@aa:/opt#docker run -d -p 80:80 --name nginx nginx:1.0

http://ip:80

相关推荐
zdd567891 小时前
行存表与列存表简述
运维·postgresql
福尔摩斯张1 小时前
Linux的pthread_self函数详解:多线程编程中的身份标识器(超详细)
linux·运维·服务器·网络·网络协议·tcp/ip·php
2401_832298102 小时前
一云多芯时代:云服务器如何打破芯片架构壁垒
运维·服务器·架构
Web极客码2 小时前
如何在 Linux 中终止一个进程?
linux·运维·服务器
一枚正在学习的小白2 小时前
prometheus监控对外服务
运维·prometheus
tzhou644522 小时前
Docker Compose 编排与 Harbor 私有仓库
运维·docker·容器
A13247053123 小时前
防火墙配置入门:保护你的服务器
linux·运维·服务器·网络
CS Beginner3 小时前
【Linux】快速配置wifi和SSH服务
linux·运维·ssh
我也要当昏君3 小时前
第一节(代入排除法)
运维
become__better3 小时前
判断ceph osd 节点磁盘异常
linux·运维·ceph