diff --git "a/01 NGINX Plus \345\256\211\350\243\205\351\203\250\347\275\262/Readme.md" "b/01 NGINX Plus \345\256\211\350\243\205\351\203\250\347\275\262/Readme.md" index 1d831a5c23fb035cbdbf0900aef2708f646f3bc1..81e7e0c2f096ddbee335e0f7d8d18b322351b89e 100644 --- "a/01 NGINX Plus \345\256\211\350\243\205\351\203\250\347\275\262/Readme.md" +++ "b/01 NGINX Plus \345\256\211\350\243\205\351\203\250\347\275\262/Readme.md" @@ -469,3 +469,71 @@ 刚才的环境中能否启动多个NGINX Plus实例,是否会冲突? +# 实验3 Docker环境安装 + +需要提前准备好带有Docker的Linux环境,推荐20.10以上版本 + +## 实验步骤 + +1. 将下载好的 nginx-mgmt-suite-acm-trail.crt 和 nginx-mgmt-suite-acm-trail.key 文件导入到/root/Docker文件夹中,并重命名为 nginx-repo.crt 和 nginx-repo.key + + ```bash + mkdir -p /root/Docker + cd /root/Docker + cp nginx-mgmt-suite-acm-trail.crt /root/Docker/ssl/nginx-repo.crt + cp nginx-mgmt-suite-acm-trail.key /root/Docker/ssl/nginx-repo.key + ``` + +2. 在同个文件夹下导入 Dockerfile + + ```bash + wget https://gist.githubusercontent.com/nginx-gists/36e97fc87efb5cf0039978c8e41a34b5/raw/a28ca796fc22fa243788afafdf9fff749a7a02b8/Dockerfile + ``` + +3. 执行docker build指令制作镜像 + + ```bash + [root@centos docker]# docker build --no-cache -t nginxplus --secret id=nginx-crt,src=nginx-repo.crt --secret id=nginx-key,src=nginx-repo.key . + [+] Building 25.7s (6/6) FINISHED + => [internal] load build definition from Dockerfile 0.0s + => => transferring dockerfile: 4.21kB 0.0s + => [internal] load .dockerignore 0.0s + => => transferring context: 2B 0.0s + => [internal] load metadata for docker.io/library/debian:bullseye-slim 1.2s + => CACHED [stage-0 1/2] FROM docker.io/library/debian:bullseye-slim@sha256:7606bef5684b393434f06a50a3d1a09808fee5a0240d37da5d181b1b121 0.0s + => [stage-0 2/2] RUN --mount=type=secret,id=nginx-crt,dst=nginx-repo.crt --mount=type=secret,id=nginx-key,dst=nginx-repo.key 24.2s + => exporting to image 0.2s + => => exporting layers 0.2s + => => writing image sha256:bdb678abc3c94c5d298db36dd164588747f07e79a681e31760388d79a63656ec 0.0s + => => naming to docker.io/library/nginxplus + ``` + +4. 查看镜像 + + ```bash + [root@7ea1cc51-c56e-4e07-9f54-443b288a6832 docker]# docker images + REPOSITORY TAG IMAGE ID CREATED SIZE + nginxplus latest bdb678abc3c9 About a minute ago 93.4MB + ``` + +5. 创建一个容器 + + ```bash + docker run --name mynginxplus -p 80:80 -d nginxplus + ``` + +6. 查看容器运行情况 + + ```bash + [root@7ea1cc51-c56e-4e07-9f54-443b288a6832 docker]# docker ps | grep nginx + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + d71576a9c297 nginxplus "nginx -g 'daemon of…" 7 minutes ago Up 7 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp mynginxplus + ``` + +7. 进入容器,查看nginx版本 + + ```bash + [root@centos docker]# docker exec -ti d71576a9c297 /bin/bash + root@d71576a9c297:/# nginx -v + nginx version: nginx/1.23.4 (nginx-plus-r29) + ``` \ No newline at end of file