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

相关推荐
云和数据.ChenGuang44 分钟前
关闭 GitLab 升级提示的详细方法
运维·自动化·gitlab·es运维
007php0071 小时前
服务器上PHP环境安装与更新版本和扩展(安装PHP、Nginx、Redis、Swoole和OPcache)
运维·服务器·后端·nginx·golang·测试用例·php
core5127 小时前
prometheus+grafana接入nginx实战
nginx·grafana·prometheus·监控·接入·vts·vtx
saynaihe7 小时前
ubuntu 22.04 anaconda comfyui安装
linux·运维·服务器·ubuntu
企鹅与蟒蛇7 小时前
Ubuntu-25.04 Wayland桌面环境安装Anaconda3之后无法启动anaconda-navigator问题解决
linux·运维·python·ubuntu·anaconda
小蜜蜂爱编程7 小时前
ubuntu透网方案
运维·服务器·ubuntu
AI视觉网奇8 小时前
git 访问 github
运维·开发语言·docker
头发那是一根不剩了8 小时前
nginx:SSL_CTX_use_PrivateKey failed
运维·服务器
七夜zippoe9 小时前
破解 VMware 迁移难题:跨平台迁移常见问题及自动化解决方案
运维·自动化·vmware
hweiyu0010 小时前
docker简介
运维·docker·容器