docker-compose-port
Find the ip and port of a docker-compose service
This is super-useful if you want to use docker-compose locally to run servers, but want to be able to easily find the real IP and Port to connect to them.
Installation
This module is installed via npm:
$ npm install docker-compose-port
Notes
This module expects docker-machine
and docker-compose
to be in your $PATH
.
Example Usage
Say you have a web server defined in your docker-compose.yml
file:
# docker-compose.ymlwww:image: nginxports:- 80environment:NGINX_PORT: "80"
To get the IP and port to connect to it from your node code:
var dockerComposePort =request = ;;
By default it will connect to your active docker-machine host.
You can tell it to connect to a different docker-machine host by passing that through as the initial parameter.
var dockerComposePort =request = ;// connect to dev server in AWS;
API
[machine]
, service
, port
)
dockerComposePort(Connect to the specified docker-compose machine
, service
and port
.
If machine
is not provided, it will default to the "active" docker machine.
[machine]
)
dockerIp(Get the IP of a given docker-machine.
If machine
is not provided, it will default to the "active" docker machine.
Eg:
var dockerIp = dockerIp;;// 192.168.99.200j
service
, port
)
dockerPort(Gets the actual port for the service on the active docker host.
Eg:
var dockerPort = dockerPort;;// 32774