Docker - Port

> Virtualization - (Virtual Machine|Container) > Docker

1 - About

Port Management in docker.

Advertising

3 - Management

3.1 - List

docker port list port mappings or a specific mapping for the container

3.1.1 - All

docker port containerName

3.1.2 - one

Look up what port is mapped externally to port 5000 inside the container.

docker port nostalgic_morse 5000
0.0.0.0:49155

3.2 - Redirection

Redirecting the port 80 from the host to the port 80 of the container

Format

-p IP:host_port:container_port 
#or 
-p IP::port
docker run -d -p 80:80 user/image
Advertising

3.3 - Expose

In a dockerfile, you can open a port (expose it) with the expose command

EXPOSE 80

3.4 - Find

  • Find out what host port the container’s containerName port 22 is mapped to
docker port containerName 22
0.0.0.0:49154
vm/docker/port.txt · Last modified: 2019/10/07 19:54 by gerardnico