re-ports
Recursively finds docker-compose ‘ports’ declarations and prints to stdout
as CSV.
details about re-ports
This goofy little script was a chance for me to explore generator functions in JavaScript. At the place I work, there was a security directive to not expose ports from your localhost
to the broader internet. If you don’t know, Docker’s “default” port declarations, e.g., 80:8080
, will bind the Docker network’s 8080
to your public IP address’ port 80
(Jeff Geerling has an excellent article on this). Try it out!
- find your public IP address (Nord VPN’s tool should work)
- start your Docker container
- visit your public IP address + port, e.g.,
123.456.789.123:80
- be afraid…
- fix your port declarations by adding your
localhost
IP address to your port declarations, e.g.,"127.0.0.1:80:8080"
So anyway, this silly CLI1 tool will recursively search through the path you give it for /docker-compose.*.yml$/
2, printing to stdout
the ports
declarations it finds in CSV format. Because I used generator functions, the code lazily evaluates the recursive tree
- loading only what needs to be held in memory
- processing files as they are evaluated (instead of needing to first load the entire tree)