docker学习(5) docker实战练习: 部署nginx、tomcat

部署nginx:

1. 搜索镜像 docker search nginx

2.拉取镜像 docker pull nginx 拉取最新nginx

3. 运行,修改默认端口为3344,名字改为nginx02(注:需要开启3344端口)

[root@wangstudy home]# docker run -d --name nginx02 -p 3344:80 nginx
7e6f7e37725d5ab44b633fc47f08f408fa1c2ee5ab23d238eab6999983a5ab49
[root@wangstudy home]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
7e6f7e37725d        nginx               "nginx -g 'daemon of…"   6 seconds ago       Up 6 seconds        0.0.0.0:3344->80/tcp   nginx02
daa744f190de        nginx               "nginx -g 'daemon of…"   8 minutes ago       Up 8 minutes        80/tcp                 nginx01
[root@wangstudy home]# curl localhost:3344
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

显示本机可以访问,同时公网也可访问

 进入nginx02容器,查看内容

安装tomcat

官网命令:docker run -it --rm tomcat:9.0 --rm用完即删,用完即删

[root@wangstudy /]# docker run -it --rm tomcat:9.0
Unable to find image 'tomcat:
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值