简体   繁体   中英

Remap ports on internal network in docker-compose

I'm using docker-compose to start services foo and bar which both run apps that bind to port 8080 .

Is it possible to remap these ports on the internal docker network as foo:80 and bar:80 ?

I obviously don't want them exposed to host:80 .

As a workaround I now use socat as a port forwarder. It's obviously not suited for production environment, but for local development it seems sufficient:

nohup sudo /usr/bin/socat -d tcp4-listen:80,fork,reuseaddr tcp4:127.0.0.1:8080 </dev/null >socat.log 2>&1 &

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM