Docker部署常见应用-Tomcat & Nginx

Docker部署常见应用-Tomcat & Nginx

全部操作均在 "禁用防火墙" 状态演示;

systemctl stop firewalld

部署的基本流程

搜索镜像 -> 拉取镜像 -> 创建专用目录 -> 运行容器 -> 测试

3.部署Tomcat

3.1 搜索镜像

docker search tomcat

3.2 拉取镜像

docker pull tomcat

3.3 创建tomcat专用目录

mkdir tomcat

3.4 运行容器

临时容器

docker run --name temp -itd tomcat

docker cp temp:/usr/local/tomcat/conf ./tomcat/

docker rm -f temp

正式容器

docker run --name mytomcat -itd

-p 8080:8080

-v /root/tomcat/conf:/usr/local/tomcat/conf

-v /root/tomcat/webapps:/usr/local/tomcat/webapps

tomcat

3.5 测试

宿主机器

/root/tomcat/webapps中创建目录myweb,里面创建文件index.html

浏览器访问 http://192.168.56.101:8080/myweb/index.html

4.部署Nginx

4.1 搜索镜像

docker search nginx

4.2 拉取镜像

docker pull nginx

4.3 创建nginx专用目录

mkdir nginx

4.4 运行容器

临时容器

docker run --name temp -itd nginx

docker cp temp:/etc/nginx/nginx.conf ./nginx/nginx.conf # 主配置(nginx.conf)

docker cp temp:/etc/nginx/conf.d ./nginx/ # 从配置(default.conf)

docker cp temp:/usr/share/nginx/html ./nginx/

docker rm -f temp

正式容器

docker run --name mynginx -itd

-p 80:80

-v /root/nginx/conf.d:/etc/nginx/conf.d

-v /root/nginx/html:/usr/share/nginx/html/

-v /root/nginx/nginx.conf:/etc/nginx/nginx.conf

nginx

4.5 测试

外部机器访问 http://192.168.56.101:80

相关推荐
凡人叶枫2 小时前
Effective C++ 条款28:避免使用 handles 指向对象内部
linux·服务器·开发语言·c++·嵌入式开发
AI帮小忙2 小时前
Debian系linux操作系统里安装OpenClaw
linux·运维·debian
极创信息2 小时前
Linux挖矿病毒深度清理实战教程,从进程隐藏、Rootkit驻留到彻底根除
java·大数据·linux·运维·安全·tomcat·健康医疗
weixin_307779133 小时前
Python写入Shell文件使用Linux系统的换行符
linux·开发语言·python·自动化
liulilittle4 小时前
Linux Swap 文件配置与持久化(虚拟内存)
linux·运维·服务器
青梅橘子皮4 小时前
Linux---进程控制(2)(进程程序替换)
linux·c++·算法
零陵上将军_xdr4 小时前
从沙子到CPU——计算机硬件基础入门
linux·运维·硬件架构
vortex54 小时前
Linux 命令工具箱:util-linux 与 GNU Coreutils
linux·运维·gnu
荒--4 小时前
MSF 使用
linux·运维·服务器
狮子再回头5 小时前
relhat9.1 sshd配置
linux·服务器·网络