1.获取镜像文件
#先搜索一下镜像文件是否存在
[root@localhost ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 18849 [OK]
unit Official build of NGINX Unit: Universal Web … 8 [OK]
nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 108
nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo… 75
nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN… 33
nginx/unit NGINX Unit is a dynamic web and application … 64
nginxinc/nginx-s3-gateway Authenticating and caching gateway based on … 1
nginx/nginx-ingress-operator NGINX Ingress Operator for NGINX and NGINX P… 0
nginxinc/amplify-agent NGINX Amplify Agent docker repository 1
nginx/nginx-quic-qns NGINX QUIC interop 1
nginxinc/ingress-demo Ingress Demo 4
nginxproxy/nginx-proxy Automated Nginx reverse proxy for docker con… 98
nginxproxy/acme-companion Automated ACME SSL certificate generation fo… 120
bitnami/nginx Bitnami nginx Docker Image 171 [OK]
bitnami/nginx-ingress-controller Bitnami Docker Image for NGINX Ingress Contr… 29 [OK]
ubuntu/nginx Nginx, a high-performance reverse proxy & we… 97
nginxinc/nginmesh_proxy_debug 0
nginxproxy/docker-gen Generate files from docker container meta-da… 12
nginxinc/mra-fakes3 0
kasmweb/nginx An Nginx image based off nginx:alpine and in… 6
rancher/nginx-ingress-controller 11
nginxinc/ngx-rust-tool 0
nginxinc/mra_python_base 0
nginxinc/nginmesh_proxy_init 0
rancher/nginx-ingress-controller-defaultbackend 2
#拉取,下载镜像
docker pull nginx
[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Pull complete
a9edb18cadd1: Pull complete
589b7251471a: Pull complete
186b1aaa4aa6: Pull complete
b4df32aa5a72: Pull complete
a0bcbecc962e: Pull complete
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
#查看本地的docker镜像有哪些
[root@localhost ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 19 months ago 141MB
#运行改Nginx镜像, 运行出具体的容器,然后这个容器中,就跑着一个Nginx服务
#运行镜像的命令,参数如下
docker run 参数 镜像的名字/id
# -d 后台运行容器
# -p 80:80 端口映射 宿主机端口:容器内端口 你访问宿主机的80端口,也就访问到了容器内的端口
#运行结果如下,docker run 命令会返回一个容器的id
[root@localhost ~]# docker run -d -p 80:80 nginx
10df2fecc26b8599ffd833d9763cf12009495ccb20d526b7bc0f00063c922ca7
#查看容器是否在运行
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10df2fecc26b nginx "/docker-entrypoint.…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp boring_hopper
#此时访问宿主机的80端口,可以看到Nginx界面
ip:80
#停止容器命令
docker stop 容器id
如何用docker运行Nginx
最新推荐文章于 2024-07-25 21:38:09 发布