Publishes the service only to the local machine.
Section: Ports and Networks
Bind only on localhost
yaml
yaml
services:
db:
image: postgres:16
ports:
- "127.0.0.1:5432:5432"Explanation
Useful for local databases not meant for LAN exposure.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Ports and Networks
Attach services to custom network
Defines multiple named networks for segmentation.
Named volume for persistent data
Stores database data in a managed named volume.