How to Use the Docker Port Command

本文介绍了如何使用Docker的port命令查看容器的公开端口映射,包括如何获取容器ID或名称,以及命令执行后显示的内部端口到主机端口的映射示例。该命令仅适用于运行中的容器,有助于从主机访问容器内的服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The docker port command is used to display the public-facing port(s) of a container. It shows the mapping between the container’s internal port and the corresponding host port.

To use the docker port command, you can follow these steps:

  1. Make sure you have Docker installed and running on your system.

  2. Open a terminal or command prompt.

  3. To view the port mappings of a running container, you need to know the container’s ID or name. You can find the ID or name of the container by using the docker ps command:

    docker ps
    

    This will display a list of running containers along with their details.

  4. Once you have the container ID or name, you can use the docker port command followed by the container ID or name:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值