Docker Hub 地址:https://hub.docker.com/
Nginx镜像地址:https://hub.docker.com/_/nginx
1、搜索 Nginx 镜像
[root@localhost home]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 16726 [OK]
bitnami/nginx Bitnami nginx Docker Image 124 [OK]
ubuntu/nginx Nginx, a high-performance reverse proxy & we… 46
bitnami/nginx-ingress-controller Bitnami Docker Image for NGINX Ingress Contr… 17 [OK]
rancher/nginx-ingress-controller 10
ibmcom/nginx-ingress-controller Docker Image for IBM Cloud Private-CE (Commu… 4
bitnami/nginx-ldap-auth-daemon 3
vmware/nginx 2
bitnami/nginx-exporter 2
rancher/nginx-ingress-controller-defaultbackend 2
circleci/nginx This image is for internal use 2
vmware/nginx-photon 1
bitnami/nginx-intel 1
rancher/nginx 1
wallarm/nginx-ingress-controller Kubernetes Ingress Controller with Wallarm e… 1
rancher/nginx-conf 0
rancher/nginx-ssl 0
rancher/nginx-ingress-controller-amd64 0
continuumio/nginx-ingress-ws 0
ibmcom/nginx-ppc64le Docker image for nginx-ppc64le 0
ibmcom/nginx-ingress-controller-ppc64le Docker Image for IBM Cloud Private-CE (Commu… 0
kasmweb/nginx An Nginx image based off nginx:alpine and in… 0
rancher/nginx-proxy 0
wallarm/nginx-ingress-controller-amd64 Kubernetes Ingress Controller with Wallarm e… 0
ibmcom/nginx-ingress-controller-amd64 0
2、下载Nginx镜像
[root@localhost home]# docker pull nginx
3、查看下载好的 Nginx 镜像
[root@localhost home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 4 months ago 141MB
4、后台运行Nginx
[root@localhost home]# docker run -d --name nginx01 -p 3344:80 nginx #后台运行Nginx,并指定名称为“nginx01”,将宿主机的3344端口映射到Nginx容器的80端口,可以通过 “宿主机ip地址:3344” 访问到Nginx(Nginx默认端口为80)
1527d7f9357a63da0a3a3f61968169cbbcfc10686247c269d786c0d7636631a8 # 显示容器id,说明启动成功
5、查看 Nginx 镜像运行实例(容器)
[root@localhost home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1527d7f9357a nginx "/docker-entrypoint.…" 4 minutes ago Up 4 minutes 0.0.0.0:3344->80/tcp nginx01 # 显示该条信息,说明Nginx镜像容器正在运行
6、本地测试访问 Nginx
[root@localhost home]# 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>
|