Skip to content

Instantly share code, notes, and snippets.

@hoai
Forked from ThinhPhan/docker-expose-vs-ports.md
Created December 5, 2023 15:09
Show Gist options
  • Save hoai/2e79f41538da4610cfdf974bac8a5316 to your computer and use it in GitHub Desktop.
Save hoai/2e79f41538da4610cfdf974bac8a5316 to your computer and use it in GitHub Desktop.
Docker expose vs ports

ports

  1. Activates the container to listen for specified port(s) from the world outside of the docker(can be same host machine or a different machine) AND also accessible world inside docker.
  2. More than one port can be specified (that's is why ports not port)

docker port

expose

  1. Activates container to listen for a specific port only from the world inside of docker AND not accessible world outside of the docker.
  2. More than one port can be specified

docker expose

Links (for review later) What is the difference between docker-compose ports vs expose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment