Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docker-tools

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker-tools - npm Package Compare versions

Comparing version 0.0.2 to 1.0.0

LICENSE

9

lib/createDockerContainerOptions.js

@@ -30,3 +30,12 @@ module.exports = function createDockerContainerOptions (spec) {

if (spec.hostPort && spec.port) {
options['HostConfig']['PortBindings'] = {};
if (typeof spec.hostPort === 'number') {
options['HostConfig']['PortBindings']['' + spec.port + '/tcp'] = [{
'HostPort': '' + spec.hostPort
}];
}
}
return options;
};

4

package.json
{
"name": "docker-tools",
"description": "Tools for working with Docker containers in Node.js.",
"version": "0.0.2",
"version": "1.0.0",
"main": "index.js",
"author": "Gustav Nikolaj Olsen @gustavnikolaj <gno@one.com>",
"license": "BSD-3-Clause",
"scripts": {

@@ -7,0 +9,0 @@ "lint": "onelint",

@@ -17,2 +17,37 @@ var expect = require('unexpected');

});
it("should map 'hostPort' to PortBindings", function () {
return expect(createDockerContainerOptions({
image: 'redis',
port: 5432,
hostPort: 54321
}), 'to equal', {
Image: 'redis',
ExposedPorts: {
'5432/tcp': {}
},
HostConfig: {
PublishAllPorts: true,
PortBindings: {
'5432/tcp': [{
HostPort: '54321'
}]
}
}
});
});
it("should not map 'hostPort' to PortBindings of 'port' has not been configured", function () {
return expect(createDockerContainerOptions({
image: 'redis',
hostPort: 54321
}), 'to equal', {
Image: 'redis',
ExposedPorts: undefined,
HostConfig: {
PublishAllPorts: true,
PortBindings: undefined
}
});
});
});
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