4-Docker命令之docker port

2023-12-13 04:26:27

1.docker port介绍

docker port命令是用于列出docker容器的端口映射

2.docker port用法

docker port container?[PRIVATE_PORT[/PROTO]]

[root@centos79 ~]# docker port --help

Usage:  docker port CONTAINER [PRIVATE_PORT[/PROTO]]

List port mappings or a specific mapping for the container

Aliases:
  docker container port, docker port
[root@centos79 ~]# 

3.实例

3.1.列出docker容器的端口映射

命令:

docker port 42574

[root@centos79 ~]# docker ps | grep centos-nginx
425747b4385b   centos-nginx:1.0       "nginx -g 'daemon of…"   4 days ago    Up About an hour   0.0.0.0:80->80/tcp, :::80->80/tcp                                                      centos-nginx
[root@centos79 ~]# docker port 42574
80/tcp -> 0.0.0.0:80
80/tcp -> [::]:80
[root@centos79 ~]# 

3.2.列出指定协议的docker容器端口映射

命令:

docker port 42574 80/tcp

[root@centos79 ~]# docker ps | grep centos-nginx
425747b4385b   centos-nginx:1.0       "nginx -g 'daemon of…"   4 days ago    Up About an hour   0.0.0.0:80->80/tcp, :::80->80/tcp                                                      centos-nginx
[root@centos79 ~]# docker port 42574 80/tcp
0.0.0.0:80
[::]:80
[root@centos79 ~]# 

文章来源:https://blog.csdn.net/z19861216/article/details/134638506
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。