Docker安装稳定版本nginx-1.26.2

Linux 安装稳定版本nginx-1.20.2

1、下载镜像、场景配置文件目录

bash 复制代码
[root@Tseng ~]# docker pull nginx:1.26.2
1.26.2: Pulling from library/nginx
2d429b9e73a6: Pull complete 
40a0d865309c: Pull complete 
a949b43e642c: Pull complete 
8a756fb620a9: Pull complete 
93a507cb9390: Pull complete 
68b64c40132b: Pull complete 
b1d9628fed3d: Pull complete 
Digest: sha256:4931f9bbbc031a52bb6cb11ea90df5507d511d1b7d28421e6ddb3b6ae7d90e2d
Status: Downloaded newer image for nginx:1.26.2
[root@Tseng  ~]#
[root@Tseng  ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               1.26.2              f87a52ac001c        3 months ago        188MB
redis               6.0.6               1319b1eaa0b7        4 years ago         104MB
mysql               8.0.18              ed1ffcb5eff3        4 years ago         456MB

[root@Tseng ~]# cd /data
[root@Tseng  data]# mkdir -p /data/nginx/conf
[root@Tseng  data]# mkdir -p /data/nginx/html
[root@Tseng  data]# mkdir -p /data/nginx/logs
[root@Tseng  data]#

2、复制容器中配置文件

bash 复制代码
[root@Tseng conf]# docker run -d nginx:1.26.2
dc028856c23770b255fe5914b4fbcd2069fb2787ae809b956e812ee3070b8cb6
[root@Tseng conf]# docker cp dc02:/etc/nginx/nginx.conf /data/nginx/conf/nginx.conf
[root@Tseng conf]# docker cp dc02:/etc/nginx/conf.d /data/nginx/conf/conf.d
[root@Tseng conf]# docker cp dc02:/usr/share/nginx/html/ /data/nginx
[root@Tseng conf]# ls
conf.d  nginx.conf
[root@Tseng conf]# cd ..
[root@Tseng nginx]# ls
conf  html  logs
[root@Tseng nginx]# cd html/
[root@Tseng html]# ls
50x.html  index.html
[root@Tseng html]# 

3、删除测试容器

bash 复制代码
[root@Tseng html]# docker stop dc02
dc02
[root@Tseng html]# docker rm dc02
dc02
[root@Tseng html]#

4、启动新的Nginx容器

bash 复制代码
[root@Tseng html]# docker run -d -p 80:80 --name nginx --privileged --restart always -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/conf/conf.d:/etc/nginx/conf.d -v /data/nginx/html:/usr/share/nginx/html -v /data/nginx/log:/var/log/nginx docker.io/nginx:1.26.2
513a77a470fa4d4a75f46fc20aa301533a1a17429717d816a2f340a0b8ad2a64
[root@Tseng html]#

5、访问服务器外网IP地址(确保服务器配置的安全组 80端口已打开)

相关推荐
java_logo20 分钟前
Docker 部署 Gotenberg 完整教程:Compose 搭建文档转 PDF API
docker·pdf·chromium·libreoffice·文档转换·轩辕镜像·gotenberg
云计算练习生23 分钟前
什么是系统调用?为什么程序访问硬件必须经过它
linux·windows·操作系统·系统调用·操作系统原理
闲云野鹤在人间1 小时前
docker 入门 | 第7章 容器监控 和 第8章 容器日志 详解
运维·docker·容器·架构·云计算
玄芯散人1 小时前
【筑基·059】Linux命令行入门:工程师的操作系统
linux·操作系统·命令行
Experience-摆渡1 小时前
开源RAG知识库WeKnora深度调研:让知识自己长成体系
爬虫·docker·开源·rag
闲云野鹤在人间1 小时前
docker 入门 | 第5章 网络详解
网络·docker·架构·华为云·php
半仙白桑1 小时前
内核篇第二讲:Linux exec 函数族详解
linux·linux驱动
AR-26710-1 小时前
Linux Day7——建组/用户、umask、Python脚本
linux·python
吴声子夜歌2 小时前
Shell编程实例——内务及管理任务(一)
linux·运维·shell
byte轻骑兵2 小时前
【BlueZ 】input 模块:蓝牙鼠标/键盘等输入设备的基础适配逻辑
linux·人工智能·bluez·电脑蓝牙·嵌入式蓝牙