Skip to content

Commit

Permalink
Added FORCE_PUBLIC_IP option
Browse files Browse the repository at this point in the history
This option forces to write the specified public IP into the directory even if the host binding IP is specified in the docker run options.
  • Loading branch information
upcFrost committed Apr 7, 2016
1 parent f612926 commit 98a9cec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ All params are optional
* `HOSTNAME`: Hostname of the system
* `REGISTER=public`: Register only Ports which binds to the host interface (docker -p)
* `REGISTER_PUBLIC_IP=10.0.1.1`: IP if Hostbinding dont specify any (docker -p 80:80 instead of docker -p 10.0.1.1:80:80)
* `FORCE_PUBLIC_IP`: Set to force binding to the public IP even if the real binding is specified, default: not set
* `SKYDNS_ETCD_PREFIX`: `/skydns/local/skydns`
* `VULCAND_ETCD_PREFIX`: `/skydns/local/skydns`
<br>
Expand Down
5 changes: 4 additions & 1 deletion lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ Container.prototype.getServices = function() {
debug('Omit container ' + self.cid + ' cause no exposed hostPort');
return false;
}
if(!portCfg.hostIP || portCfg.hostIP === '0.0.0.0') {
if(!portCfg.hostIP || portCfg.hostIP === '0.0.0.0' || process.env.FORCE_PUBLIC_IP) {
if(!process.env.REGISTER_PUBLIC_IP) {
console.log('Error: Port ' + portCfg.port + ' from ' + self.cid + ' listens on all interface but u did not provide REGISTER_PUBLIC_IP');
return false;
}
if (process.env.FORCE_PUBLIC_IP) {
debug('Forcing public IP: ' + process.env.REGISTER_PUBLIC_IP);
}
service.ip = process.env.REGISTER_PUBLIC_IP;
} else {
service.ip = portCfg.hostIP;
Expand Down

0 comments on commit 98a9cec

Please sign in to comment.