Docker安装Nginx

Docker安装Nginx

1. 搜索镜像

#Ps建议去dockerHub搜索,可以看到帮助文档
[root@VM-16-11-centos ~]# docker search nginx
NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                              Official build of Nginx.                        14801     [OK]       
jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   2021                 [OK]
richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   813                  [OK]
jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   184                  
linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   143                  
tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   122                  [OK]
jlesage/nginx-proxy-manager        Docker container for Nginx Proxy Manager        106                  [OK]
bitnami/nginx                      Bitnami nginx Docker Image                      96                   [OK]
alfg/nginx-rtmp                    NGINX, nginx-rtmp-module and FFmpeg from sou…   92                   [OK]
jasonrivers/nginx-rtmp             Docker images to host RTMP streams using NGI…   89                   [OK]
nginxdemos/hello                   NGINX webserver that serves a simple page co…   67                   [OK]
privatebin/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & Al…   53                   [OK]
nginx/nginx-ingress                NGINX Ingress Controller for Kubernetes         51                   
nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  33                   
staticfloat/nginx-certbot          Opinionated setup for automatic TLS certs lo…   20                   [OK]
schmunk42/nginx-redirect           A very simple container to redirect HTTP tra…   19                   [OK]
nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter                       17                   
centos/nginx-112-centos7           Platform for running nginx 1.12 or building …   15                   
centos/nginx-18-centos7            Platform for running nginx 1.8 or building n…   13                   
raulr/nginx-wordpress              Nginx front-end for the official wordpress:f…   13                   [OK]
flashspys/nginx-static             Super Lightweight Nginx Image                   10                   [OK]
bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   8                    [OK]
mailu/nginx                        Mailu nginx frontend                            8                    [OK]
ansibleplaybookbundle/nginx-apb    An APB to deploy NGINX                          2                    [OK]
wodby/nginx                        Generic nginx                                   1                    [OK]

2. 下载镜像

[root@VM-16-11-centos ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
f7ec5a41d630: Pull complete 
aa1efa14b3bf: Pull complete 
b78b95af9b17: Pull complete 
c7d6bca2b8dc: Pull complete 
cf16cd8e71e0: Pull complete 
0241c68333ef: Pull complete 
Digest: sha256:75a55d33ecc73c2a242450a9f1cc858499d468f077ea942867e662c247b5e412
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

3. 运行测试

[root@VM-16-11-centos ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    62d49f9bab67   2 weeks ago    133MB
centos       latest    300e315adb2f   4 months ago   209MB

# -d 后台运行
# --name 给容器命名
# -p 宿主机端口:容器内部端口 (映射)
[root@VM-16-11-centos ~]# docker run -d --name nginx01 -p 3344:80 nginx
35f318313380655ffe6d87ce035b0ea60382a867c92b0252616cdca37410a0d3
[root@VM-16-11-centos ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                   NAMES
35f318313380   nginx     "/docker-entrypoint.…"   38 minutes ago   Up 38 minutes   0.0.0.0:3344->80/tcp, :::3344->80/tcp   nginx01
[root@VM-16-11-centos ~]# 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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值