1、搜索镜像

[root@localhost ~]# docker search nginx
NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                        18662     [OK]  

2、拉取镜像

[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
[root@localhost ~]# 

3、启动容器

查看容器镜像

[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nginx        latest    605c77e624dd   17 months ago   141MB
mysql        latest    3218b38490ce   18 months ago   516MB
centos       latest    5d0da3dc9764   21 months ago   231MB
[root@localhost ~]# docker run -d --name nginx01 -p 3500:80 nginx
7e501365832de7871d6fd40a5cdac2f0f75b5c8e964c5d08c3f6173720602340
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED              STATUS              PORTS                                   NAMES
7e501365832d   nginx     "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:3500->80/tcp, :::3500->80/tcp   nginx01
[root@localhost ~]# 

4、测试访问nginx页面

[root@localhost ~]# curl localhost:3500
<!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@localhost ~]# 

2023-06-21_154521.jpg

最后修改:2023 年 06 月 21 日
如果觉得我的文章对你有用,请随意赞赏