:::info
docker仓库:https://hub.docker.com/
:::
[root@ecs-214025 admin]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 16994 [OK] linuxserver/nginx An Nginx container, brought to you by LinuxS… 169 bitnami/nginx Bitnami nginx Docker Image 133 [OK] ubuntu/nginx Nginx, a high-performance reverse proxy & we… 52 bitnami/nginx-ingress-controller Bitnami Docker Image for NGINX Ingress Contr… 18 [OK] rancher/nginx-ingress-controller 10 clearlinux/nginx Nginx reverse proxy server with the benefits… 4 ibmcom/nginx-ingress-controller Docker Image for IBM Cloud Private-CE (Commu… 4 bitnami/nginx-ldap-auth-daemon 3 rancher/nginx 2 bitnami/nginx-exporter 2 vmware/nginx 2 rancher/nginx-ingress-controller-defaultbackend 2 circleci/nginx This image is for internal use 2 vmware/nginx-photon 1 rapidfort/nginx RapidFort optimized, hardened image for NGINX 1 wallarm/nginx-ingress-controller Kubernetes Ingress Controller with Wallarm e… 1 bitnami/nginx-intel 1 kasmweb/nginx An Nginx image based off nginx:alpine and in… 1 rancher/nginx-conf 0 ibmcom/nginx-ingress-controller-ppc64le Docker Image for IBM Cloud Private-CE (Commu… 0 continuumio/nginx-ingress-ws 0 rancher/nginx-ingress-controller-amd64 0 ibmcom/nginx-ppc64le Docker image for nginx-ppc64le 0 rancher/nginx-ssl 0 [root@ecs-214025 admin]#
[root@ecs-214025 admin]# docker pull nginx Using default tag: latest latest: Pulling from library/nginx b85a868b505f: Pull complete f4407ba1f103: Pull complete 4a7307612456: Pull complete 935cecace2a0: Pull complete 8f46223e4234: Pull complete fe0ef4c895f5: Pull complete Digest: sha256:10f14ffa93f8dedf1057897b745e5ac72ac5655c299dade0aa434c71557697ea Status: Downloaded newer image for nginx:latest docker.io/library/nginx:latest [root@ecs-214025 admin]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 55f4b40fe486 3 days ago 142MB mysql latest 968083d5be36 3 days ago 524MB hello-world latest feb5d9fea6a5 9 months ago 13.3kB centos latest 5d0da3dc9764 9 months ago 231MB [root@ecs-214025 admin]#
[root@ecs-214025 admin]# docker run -d --name nginx01 -p 3344:80 nginx 2d03ed78527d4129caeced92374f87588241beba40ceb2ec20bb53c87d35a257 [root@ecs-214025 admin]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d03ed78527d nginx "/docker-entrypoint.…" 6 seconds ago Up 5 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01 [root@ecs-214025 admin]#
:::info
端口暴露原理
:::
[root@ecs-214025 admin]# 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@ecs-214025 admin]#
[root@ecs-214025 admin]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d03ed78527d nginx "/docker-entrypoint.…" 12 minutes ago Up 12 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01 [root@ecs-214025 admin]# docker exec -it nginx01 /bin/bash root@2d03ed78527d:/# whereis nginx nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx root@2d03ed78527d:/# ls /etc/nginx/ conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params root@2d03ed78527d:/#
root@2d03ed78527d:/# exit exit [root@ecs-214025 admin]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d03ed78527d nginx "/docker-entrypoint.…" 19 minutes ago Up 19 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01 [root@ecs-214025 admin]# docker stop nginx01 nginx01 [root@ecs-214025 admin]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@ecs-214025 admin]# curl locallost:3344 curl: (6) Could not resolve host: locallost; Unknown error [root@ecs-214025 admin]#