Connecting Containers to the Outside
Port mapping lets you access container services from your host machine. By default, containers are isolated from the outside network.
Port Mapping Syntax
Mapping Options
80/tcp
Map multiple ports:
$ docker run -d -p 80:80 -p 443:443 nginx
Map to specific network interface:
$ docker run -d -p 127.0.0.1:8080:80 nginx
โ Only accessible from localhost (not from network)
EXPOSE vs -p