aroooo
aroooo

Reputation: 5086

Docker: Internal Ports

I'm new to docker and wondering why so many examples of docker-compose map ports from internal to external instead of just keeping them the same. For example, one postgres example I saw mapped 4612:5432.

Is there a reason people don't just keep it 5432:5432?

Upvotes: 3

Views: 2828

Answers (2)

sashimi
sashimi

Reputation: 1304

There may be different reasons not to map to same port on host: doing this allows to have multiple Postgres running on separate ports and tweak them in case for some reason you want different ports in DEV/PROD.

Upvotes: 3

HelloThere
HelloThere

Reputation: 1060

For local dev env, except for port conflicting issues, there is no other reason. Unlike exposing ports to internet, there is no security reasons for container port mapping and exposing.

Upvotes: 1

Related Questions