vim index.html
<h1> nginx test !!! </h1>
vim repositories
http://mirrors.aliyun.com/alpine/v3.11/main
http://mirrors.aliyun.com/alpine/v3.11/community
FROM alpine
MAINTAINER yangzhanpeng
LABEL version="v100"
WORKDIR /usr/local/nginx/
ENV NG_VERSION nginx-1.18.0
COPY repositories /etc/apk/repositories
RUN apk update && apk add wget \
&& wget http://nginx.org/download/$NG_VERSION.tar.gz \
&& tar xzvf $NG_VERSION.tar.gz \
&& apk add iotop gcc libgcc libc-dev libcurl libc-utils pcre-dev zlib-dev libnfs make \
pcre pcre2 zip unzip net-tools pstree libevent libevent-dev iproute2 openssl libffi-dev openssl-dev libtool
RUN adduser -D -s /sbin/nologin nginx
WORKDIR /usr/local/nginx/$NG_VERSION
RUN ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module \
&& make && make install
ADD index.html /usr/local/nginx/html
VOLUME /usr/local/nginx/html
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80/tcp
ENTRYPOINT ["nginx"]
CMD ["-g","daemon off;"]
docker build -t nginx:v101 .
docker images
dokcer run -it -d --name nginx -p 8989:80 nginx:v101
测试之前要看主机的防火墙是否开放了端口:
永久开放8989端口:firewall-cmd --zone=public --add-port=8989/tcp --permanent
使 其 生 效:firewall-cmd --reload
查看端口是否开启:firewall-cmd --list-port
Dockerfile基于alpine 制作nginx1.18.0镜像
原文:https://www.cnblogs.com/yangzp/p/14243906.html