Docker - 在docker中部署Nginx

1、docker search 查找ngix

2、docker pull下载镜像

3、查看镜像列表

4、docker run启动容器

5、测试nginx容器是否启动成功

 

 

 

1、docker search 查找ngix

[root@node01 ~]# docker search nginx
NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                        18563     [OK]
unit                                              Official build of NGINX Unit: Universal Web …   4         [OK]
nginxproxy/nginx-proxy                            Automated Nginx reverse proxy for docker con…   87
nginxproxy/acme-companion                         Automated ACME SSL certificate generation fo…   113
bitnami/nginx                                     Bitnami nginx Docker Image                      164                  [OK]
bitnami/nginx-ingress-controller                  Bitnami Docker Image for NGINX Ingress Contr…   29                   [OK]
ubuntu/nginx                                      Nginx, a high-performance reverse proxy & we…   95
nginxproxy/docker-gen                             Generate files from docker container meta-da…   12
kasmweb/nginx                                     An Nginx image based off nginx:alpine and in…   6
rancher/nginx-ingress-controller                                                                  11
rancher/nginx-ingress-controller-defaultbackend                                                   2
bitnami/nginx-exporter                                                                            3
rancher/nginx                                                                                     2
rapidfort/nginx-ib                                RapidFort optimized, hardened image for NGIN…   10
rapidfort/nginx                                   RapidFort optimized, hardened image for NGINX   14
vmware/nginx-photon                                                                               1
bitnami/nginx-ldap-auth-daemon                                                                    3
rapidfort/nginx-official                          RapidFort optimized, hardened image for NGIN…   10
vmware/nginx                                                                                      2
rancher/nginx-conf                                                                                0
linuxserver/nginx                                 An Nginx container, brought to you by LinuxS…   201
nginxproxy/forego                                 Foreman in Go                                   0
privatebin/nginx-fpm-alpine                       PrivateBin running on an Nginx, php-fpm & Al…   72                   [OK]
bitnami/nginx-intel                                                                               1
bitnamicharts/nginx                                                                               0
[root@node01 ~]#

 

2、docker pull下载镜像

[root@node01 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
f03b40093957: Pull complete
eed12bbd6494: Pull complete
fa7eb8c8eee8: Pull complete
7ff3b2b12318: Pull complete
0f67c7de5f2c: Pull complete
831f51541d38: Pull complete
Digest: sha256:af296b188c7b7df99ba960ca614439c99cb7cf252ed7bbc23e90cfda59092305
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@node01 ~]#

 

3、docker images查看镜像列表

[root@node01 ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
nginx         latest    f9c14fe76d50   3 days ago      143MB
hello-world   latest    9c7a54a9a43c   3 weeks ago     13.3kB
mysql         latest    8189e588b0e8   5 weeks ago     564MB
centos        latest    5d0da3dc9764   20 months ago   231MB
[root@node01 ~]#
[root@node01 ~]#

 

4、docker run启动容器

[root@node01 ~]# docker run -d --name nginx01 -p 3344:80 nginx
a8c7e5cdd790f5febe9dfa7648b29e8a145c9e5314fca723cb186343bf8d605f
[root@node01 ~]#
[root@node01 ~]#
[root@node01 ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                   NAMES
a8c7e5cdd790   nginx     "/docker-entrypoint.…"   2 seconds ago    Up 2 seconds    0.0.0.0:3344->80/tcp, :::3344->80/tcp   nginx01
740ee6cbc783   centos    "bash"                   12 minutes ago   Up 12 minutes                                           reverent_bardeen
[root@node01 ~]#
[root@node01 ~]#

 

5、测试nginx容器是否启动成功

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

 

posted @ 2023-05-29 01:14  HOUHUILIN  阅读(84)  评论(0编辑  收藏  举报