• Docker 安装 Nginx


    1、查看可用的 Nginx 版本

    访问 Nginx 镜像库地址: https://hub.docker.com/_/nginx?tab=tags

    可以通过 Sort by 查看其他版本的 Nginx,默认是最新版本 nginx:latest

     

     此外,还可以用 docker search nginx 命令来查看可用nginx版本:

    brace@ubuntu:~$ sudo docker search nginx
    NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    nginx                              Official build of Nginx.                        12876               [OK]                
    jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   1755                                    [OK]
    richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   760                                     [OK]
    linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   99                                      
    bitnami/nginx                      Bitnami nginx Docker Image                      80                                      [OK]
    tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   66                                      [OK]
    jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   46                                      
    nginxdemos/hello                   NGINX webserver that serves a simple page co…   44                                      [OK]
    jlesage/nginx-proxy-manager        Docker container for Nginx Proxy Manager        36                                      [OK]
    nginx/unit                         NGINX Unit is a dynamic web and application …   36                                      
    nginx/nginx-ingress                NGINX Ingress Controller for Kubernetes         28                                      
    privatebin/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & Al…   23                                      [OK]
    schmunk42/nginx-redirect           A very simple container to redirect HTTP tra…   18                                      [OK]
    blacklabelops/nginx                Dockerized Nginx Reverse Proxy Server.          13                                      [OK]
    nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  13                                      
    raulr/nginx-wordpress              Nginx front-end for the official wordpress:f…   12                                      [OK]
    centos/nginx-18-centos7            Platform for running nginx 1.8 or building n…   12                                      
    centos/nginx-112-centos7           Platform for running nginx 1.12 or building …   12                                      
    nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter                       10                                      
    sophos/nginx-vts-exporter          Simple server that scrapes Nginx vts stats a…   7                                       [OK]
    mailu/nginx                        Mailu nginx frontend                            6                                       [OK]
    bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   4                                       [OK]
    ansibleplaybookbundle/nginx-apb    An APB to deploy NGINX                          1                                       [OK]
    wodby/nginx                        Generic nginx                                   0                                       [OK]
    centos/nginx-110-centos7           Platform for running nginx 1.10 or building …   0                                       

    2、取最新版的 Nginx 镜像

    brace@ubuntu:~$ sudo docker pull nginx:latest
    latest: Pulling from library/nginx
    68ced04f60ab: Pull complete 
    28252775b295: Downloading  12.59MB/23.92MB
    a616aa3b0bf2: Download complete 
    
    28252775b295: Downloading  12.84MB/23.92MB
    

    3、查看本地镜像

    brace@ubuntu:~$ sudo docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nginx               latest              6678c7c2e56c        3 weeks ago         127MB
    

    如果有上面显示就代表已经安装了最新版本(latest)的 nginx 镜像。

    4、运行容器

    安装完成后,我们可以使用以下命令来运行 nginx 容器:

    brace@ubuntu:~$ sudo docker run --name nginx-test -p 8080:80 -d nginx
    e93982dc24de83ce07ca86507afe9fd932d7e59f5611883d303d89fbcdd8b1ea
    

    参数说明:

    • --name nginx-test:容器名称。
    • -p 8080:80: 端口进行映射,将本地 8080 端口映射到容器内部的 80 端口。
    • -d nginx: 设置容器在在后台一直运行。

    5、安装成功

    最后我们可以通过浏览器可以直接访问 8080 端口的 nginx 服务:

  • 相关阅读:
    [leedcode 82] Remove Duplicates from Sorted List II
    [leedcode 83] Remove Duplicates from Sorted List
    [leedcode 81] Search in Rotated Sorted Array II
    [leedcode 80] Remove Duplicates from Sorted Array II
    [leedcode 79] Word Search
    2018 ICPC青岛-books(思维题)
    CodeForces 15A-Cottage Village(思维题)
    CodeForces 755A-PolandBall and Hypothesis(思维题)
    CodeForces
    UVA11624-Fire!(BFS)
  • 原文地址:https://www.cnblogs.com/mefj/p/12573924.html
Copyright © 2020-2023  润新知