alpine nginx docker image

本文最后更新于:2024年8月9日 晚上

This is a demo for build nginx docker image use nginx source code from alpine base image, let’s jump in and get started:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Dockerfile
FROM alpine:latest
RUN apk update && apk upgrade
RUN apk add build-base pcre pcre-dev openssl openssl-dev zlib zlib-dev wget curl
RUN rm -rf /var/cache/apk/*
RUN wget https://nginx.org/download/nginx-1.25.2.tar.gz
RUN tar -zxvf nginx-1.25.2.tar.gz
WORKDIR ./nginx-1.25.2
RUN ./configure --prefix=/opt/nginx
RUN make -j4
RUN make -j4 install
RUN make clean
ENV PATH $PATH:/opt/nginx/sbin
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
jason@MacbookPro  ~/Desktop/azure/containerapp/src  ll
.rw-r--r-- 453 jason 25 8 01:34 Dockerfile
jason@MacbookPro  ~/Desktop/azure/containerapp/src  docker build -t iibmer/ngx-alpine:1.25.2 .
jason@MacbookPro  ~/Desktop/azure/containerapp/src  docker images | grep iibmer/ngx
iibmer/ngx-alpine 1.25.2 b00d6f4aed3c Less than a second ago 242MB
jason@MacbookPro  ~/Desktop/azure/containerapp/src  docker run -itd -p 100:80 iibmer/ngx-alpine:1.25.2
2e7e8497166a78774495eb2da99e41d2a3c5301a6659a603f17a6d879034aebd
jason@MacbookPro  ~/Desktop/azure/containerapp/src  curl -I bo.lan:100
HTTP/1.1 200 OK
Server: nginx/1.25.2
Date: Thu, 24 Aug 2023 17:41:10 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Thu, 24 Aug 2023 17:39:10 GMT
Connection: keep-alive
ETag: "64e795be-267"
Accept-Ranges: bytes

image-20230825014046006


alpine nginx docker image
https://git.msft.vip/2023/08/24-alpine-nginx-docker-image/
作者
Jas0n0ss
发布于
2023年8月24日
更新于
2024年8月9日
许可协议