#1、搜索镜像 search#2、下载镜像 pull#3、启动镜像#搜索[root@ecs-293236 ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 17031[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
ibmcom/nginx-ingress-controller Docker Image for IBM Cloud Private-CE (Commu… 4
bitnami/nginx-ldap-auth-daemon 3
rancher/nginx 2
circleci/nginx This image is for internal use 2
bitnami/nginx-exporter 2
rancher/nginx-ingress-controller-defaultbackend 2
vmware/nginx 2
bitnami/nginx-intel 1
vmware/nginx-photon 1
kasmweb/nginx An Nginx image based off nginx:alpine and in… 1
rapidfort/nginx RapidFort optimized, hardened image for NGINX 1
wallarm/nginx-ingress-controller Kubernetes Ingress Controller with Wallarm e… 1
rancher/nginx-ssl 0
rancher/nginx-conf 0
continuumio/nginx-ingress-ws 0
rancher/nginx-ingress-controller-amd64 0
ibmcom/nginx-ingress-controller-ppc64le Docker Image for IBM Cloud Private-CE (Commu… 0
ibmcom/nginx-ppc64le Docker image for nginx-ppc64le 0
rancher/nginx-proxy 0#下载[root@ecs-293236 ~]# 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
#启动镜像# -d 后台运行# --name 给容器命名# -p 宿主机端口:容器内部端口[root@ecs-293236 ~]# docker run -d --name nginx01 -p:3344:80 nginx
092e29b73378adcac2c1b8651846a6ca6cc8a3d04dfb87f8c917c7991fa51016
[root@ecs-293236 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
092e29b73378 nginx "/docker-entrypoint.…"7 seconds ago Up 7 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
[root@ecs-293236 ~]# 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-293236 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 6 months ago 141MB
centos latest 5d0da3dc9764 9 months ago 231MB
#进入容器[root@ecs-293236 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
092e29b73378 nginx "/docker-entrypoint.…"19 minutes ago Up 19 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
[root@ecs-293236 ~]# docker exec -it nginx01 /bin/bash
root@092e29b73378:/# where is nginx
bash: where: command not found
root@092e29b73378:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@092e29b73378:/# cd /etc/nginx
root@092e29b73378:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
root@092e29b73378:/etc/nginx# exitexit[root@ecs-293236 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
092e29b73378 nginx "/docker-entrypoint.…"22 minutes ago Up 22 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
#停止容器[root@ecs-293236 ~]# docker stop 092e29b73378
092e29b73378
[root@ecs-293236 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES