New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

amicontained

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amicontained

Find out what container runtime is being used as well as features available. Ported from the Go version.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

amicontained

This package helps detect if an application is currently running in a container.

Installation

npm install amicontained

Usage / API

const amicontained = require('amicontained');

amicontained.amIContained((err, result) => {
	if (err) {
		return console.error(err);
	}

	if (result) {
		console.log('I am running in a container!');
	} else {
		console.log('I am not running in a container!');
	}
});

amicontained.runtime((err, runtime) => {
	if (err) {
		return console.error(err);
	}

	console.log(`Current container runtime is ${runtime}`);
});

amicontained.hasPIDNamespace((err, result) => {
	if (err) {
		return console.error(err);
	}

	if (result) {
		console.log('PID is namespaced!');
	} else {
		console.log('PID is not namespaced!');
	}
});

amicontained.appArmorProfile((err, profile) => {
	if (err) {
		return console.error(err);
	}

	console.log(`Current apparmor profile is:\n\n${profile}`);
});

Running this file with docker would yield:

$ docker run --rm -it my-container:latest
I am contained!
Current container runtime is docker
PID is namespaced!

Promise-based

To use the API with promises, you can do:

const amicontained = require('amicontained').promisify();

amicontained.runtime().then((result) => {
	console.log(`Current container runtime is ${runtime}`);
});

Or if your version of node supports async/await:

const amicontained = require('amicontained').promisify();

async function main() {
	const runtime = await amicontained.runtime();
	console.log(runtime);
}

main();

License

MIT

FAQs

Package last updated on 18 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc