I'm trying to retrieve the host IP using node.js running inside a Docker container.
I'm making some test and I'm using this npm package.
It seems working but I have the two following problems:
- I have to find a way to let the function waits for the response (seems not working with async/await)
- I don't know if it will behave correctly using docker swarm.
My node app is the following:
dockerhost = require(`get-docker-host`),
isInDocker = require(`is-in-docker`),
function dockerHost() {
dockerhost(async (error, result) => {
if (result) {
console.log(result);
return await result;
} else if (error) {
console.log(error);
return await error;
}
})
}
if(isInDocker()) {
console.log("My Docker host is " + dockerHost());
}