(1)docker search nginx 搜索镜像

  1. [root@localhost ~]# docker search nginx --filter stars=1000
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. nginx Official build of Nginx. 15611 [OK]
  4. jwilder/nginx-proxy Automated Nginx reverse proxy for docker con 2074 [OK]
  5. [root@localhost ~]#

(2)docker pull nginx 下载镜像

  1. [root@localhost ~]# docker pull nginx
  2. Using default tag: latest
  3. latest: Pulling from library/nginx
  4. 07aded7c29c6: Pull complete
  5. bbe0b7acc89c: Pull complete
  6. 44ac32b0bba8: Pull complete
  7. 91d6e3e593db: Pull complete
  8. 8700267f2376: Pull complete
  9. 4ce73aa6e9b0: Pull complete
  10. Digest: sha256:06e4235e95299b1d6d595c5ef4c41a9b12641f6683136c18394b858967cd1506
  11. Status: Downloaded newer image for nginx:latest
  12. docker.io/library/nginx:latest
  13. [root@localhost ~]#

(3)docker images 查看确认nginx镜像已经在本地存在

  1. [root@localhost ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. nginx latest f8f4ffc8092c 13 days ago 133MB
  4. centos latest 5d0da3dc9764 3 weeks ago 231MB
  5. [root@localhost ~]#

(4)docker run 启动docker

  1. [root@localhost ~]# docker run -d -p 80:80 --name nginx nginx
  2. 9edf0a007e2ec586fbc884acbf79864ec48d3fc80205c8258f94522825e12f29
  3. [root@localhost ~]#

(5)docker ps 查看已经启动的docker

  1. [root@localhost ~]# docker ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. 9edf0a007e2e nginx "/docker-entrypoint.…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp nginx
  4. d1df9f4c810d centos "/bin/sh -c 'while t…" 23 hours ago Up 23 hours confident_franklin
  5. [root@localhost ~]#

(6)在浏览器验证nginx安装是否成功

在浏览器打开 http://192.168.1.210:80, 其中192.168.1.210是启动docker的虚拟机的ip地址,如下即docker安装成功
image.png