docker-ip-get
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

Overview

Build Status npm npm bundle size npm codecov

This package consists of a couple of utilities to get IP addresses of containers and host from inside a docker container.

Getting Started

Install this package

using yarn:

yarn add docker-ip-get

or using npm:

npm install docker-ip-get

Here is an example usage:

First, import the library

in CommonJS format:

const dockerIpTools = require("docker-ip-get");

or in ES6 format:

import * as dockerIpTools from "docker-ip-get";

Then, use the utilities as follows:

// Get IP address of the docker host
dockerIpTools
  .getHostIp()
  .then((hostIp) => console.log(hostIp))
  .catch((err) => console.error(err));
 
// Get IP address of the docker container this script is running in
dockerIpTools
  .getContainerIp()
  .then((containerIp) => console.log(containerIp))
  .catch((err) => console.error(err));
 
// Get IP address of the docker gateway
dockerIpTools
  .getGatewayIp()
  .then((hostIp) => console.log(hostIp))
  .catch((err) => console.error(err));
 
// Check if the system is a docker container
dockerIpTools.isInDocker();

Contributing

If you encounter any issues, please feel free to post an issue here.

Any Pull Requests are welcome!!

Acknowledgements

This project was inspired by docker-ip and this stackoverflow post.

License

docker-ip-get is MIT Licensed.

/docker-ip-get/

    Package Sidebar

    Install

    npm i docker-ip-get

    Weekly Downloads

    47

    Version

    1.1.5

    License

    MIT

    Unpacked Size

    13 kB

    Total Files

    12

    Last publish

    Collaborators

    • ukalwa