Docker学习(07)——nginx部署

1. 搜索nginx镜像

[root@192 ~]# docker search nginx

2. 拉取镜像

[root@192 ~]# docker pull nginx

查看是否下载成功:

[root@192 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
centos       latest    5d0da3dc9764   10 days ago   231MB
tomcat       latest    bb832de23021   11 days ago   680MB
nginx        latest    ad4c705f24d3   2 weeks ago   133MB
mysql        latest    0716d6ebcc1a   3 weeks ago   514MB
[root@192 ~]# 

3. 启动nginx

[root@192 ~]# docker run -d --name nginx01 -p:3600:80 nginx     ------------------启动nginx
978bc911ede446d6618a07ef76d4275f5f0f3885be6dda4e49cd9a5c6d78009a
[root@192 ~]# clear
[root@192 ~]# docker ps     -----------------------查看是否启动成功
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                   NAMES
978bc911ede4   nginx     "/docker-entrypoint.…"   4 seconds ago   Up 3 seconds   0.0.0.0:3600->80/tcp, :::3600->80/tcp   nginx01
[root@192 ~]# curl localhost:3600       -----------------本机测试
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
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>
[root@192 ~]# 

参数说明:

-d 后台运行

--name 容器命名

-p  宿主机端口,容器内部端口

4. 网页测试

网页访问http://192.168.0.105:3600,其中192.168.0.105为我的服务器地址,3600为nginx代理端口。访问成功如下图所示:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值