ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

centos docker部署nginx镜像并启动

2020-12-10 10:29:43  阅读:224  来源: 互联网

标签:OK centos Nginx 7777 nginx docker NGINX


centos docker部署nginx镜像并启动

1、查询nginx镜像

[root@lChen ~]# docker search nginx
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
nginx                              Official build of Nginx.                        14133               [OK]                
jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   1921                                    [OK]
richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   796                                     [OK]
linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   131                                     
jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   118                                     
tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   106                                     [OK]
bitnami/nginx                      Bitnami nginx Docker Image                      91                                      [OK]
alfg/nginx-rtmp                    NGINX, nginx-rtmp-module and FFmpeg from sou…   81                                      [OK]
jlesage/nginx-proxy-manager        Docker container for Nginx Proxy Manager        75                                      [OK]
nginxdemos/hello                   NGINX webserver that serves a simple page co…   64                                      [OK]
nginx/nginx-ingress                NGINX Ingress Controller for Kubernetes         46                                      
privatebin/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & Al…   43                                      [OK]
nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  27                                      
schmunk42/nginx-redirect           A very simple container to redirect HTTP tra…   19                                      [OK]
staticfloat/nginx-certbot          Opinionated setup for automatic TLS certs lo…   16                                      [OK]
centos/nginx-112-centos7           Platform for running nginx 1.12 or building …   15                                      
nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter                       15                                      
raulr/nginx-wordpress              Nginx front-end for the official wordpress:f…   13                                      [OK]
centos/nginx-18-centos7            Platform for running nginx 1.8 or building n…   13                                      
flashspys/nginx-static             Super Lightweight Nginx Image                   8                                       [OK]
mailu/nginx                        Mailu nginx frontend                            8                                       [OK]
bitwarden/nginx                    The Bitwarden nginx web server acting as a r…   7                                       
bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   7                                       [OK]
ansibleplaybookbundle/nginx-apb    An APB to deploy NGINX                          1                                       [OK]
wodby/nginx                        Generic nginx     

2、拉取nginx镜像 我这里拉取最新版的nginx 如果指定版本可以用

[root@weixin ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
852e50cd189d: Pull complete 
571d7e852307: Pull complete 
addb10abd9cb: Pull complete 
d20aa7ccdb77: Pull complete 
8b03f1e11359: Pull complete 
Digest: sha256:6b1daa9462046581ac15be20277a7c75476283f969cb3a61c8725ec38d3b01c3
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

3、查看下载好的镜像,可以看到我服务器只有一 个nginx镜像 非必要

[root@weixin ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              bc9a0695f571        2 weeks ago         133MB

4、启动nginx镜像

#-d 后台启动 
#--name nginx 给这个容器起个名字,我这里还叫nginx,不写默认就是镜像名
#-p 暴漏宿 把容器的nginx端口80 映射到宿主机(服务器)端口7777 
[root@weixin ~]# docker run -d --name nginx -p 7777:80 nginx
ac0719f6af28c67ac886e8ba5b691f1b734481e381b29e2cc8d6c9be9ed90573

5、查看进程

#可以看到只有一个nginx容器正在运行 非必要
[root@weixin ~]# docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS         PORTS                  NAMES
ac0719f6af28        nginx               "/docker-entrypoint.…"   6 seconds ago       Up 5 seconds   0.0.0.0:7777->80/tcp   nginx

6、本机测试 容器的80端口映射到宿主机的7777 所以我们本机测试访问7777端口

[root@weixin ~]# curl localhost:7777
<!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>

如果都跟以上一样就说明nginx已经成功了

7、外网访问 服务器公网ip:7777

发现无法访问,因为我的是阿里云服务器,需要在阿里云安全组里面把7777放出来

在这里插入图片描述

8、配置阿里云安全组规则

在这里插入图片描述
在这里插入图片描述

9、再去访问ip+7777

可以看到已经可以访问了
在这里插入图片描述

标签:OK,centos,Nginx,7777,nginx,docker,NGINX
来源: https://blog.csdn.net/weixin_43901144/article/details/110947426

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有