🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

docker_child_process

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker_child_process

Simple docker agent to NodeJS to run scripts in a container.

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

docker_child_process

A simple docker agent at NodeJS to run scripts in a container.

Installation

Using npm:

$ npm install docker_child_process

In NodeJS:

import { createInterface } from "docker_child_process";

const dockerInstance = createInterface();

await dockerInstance.init();

await dockerInstance.exec(`echo ok`);
// # Docker: ok

const { outputs } = await dockerInstance.exec(`echo "###=> FOO=VAZ"`);

outputs; // => { FOO: "VAZ" }

const { outputs } = await dockerInstance.exec(
    `echo '###=> FOO={ "VAZ": "BIZ" }'`
);

outputs; // => { FOO: { VAZ: "BIZ" } }

const { outputs } = await dockerInstance.exec(
    `echo "### => lodash=$(npm search lodash --json -p | jq '.[0]' -r --indent 0)"`
);

outputs; // => { lodash:{"name":"lodash","scope":"unscoped","version":"4.17.21","description":"Lodash modular utilities.","keywords":["modules","stdlib","util"],"date":"2021-02-20T15:42:16.891Z","links":{"npm":"https://www.npmjs.com/package/lodash","homepage":"https://lodash.com/","repository":"https://github.com/lodash/lodash","bugs":"https://github.com/lodash/lodash/issues"},"author":{"name":"John-David Dalton","email":"john.david.dalton@gmail.com","username":"jdalton"},"publisher":{"username":"bnjmnt4n","email":"benjamin@dev.ofcr.se"},"maintainers":[{"username":"mathias","email":"mathias@qiwi.be"},{"username":"jdalton","email":"john.david.dalton@gmail.com"},{"username":"bnjmnt4n","email":"benjamin@dev.ofcr.se"}]} }

Copy files

To copy a file into the container, it's posible to call the Instance.prototype.cp() function.

const localFile = new URL("file", import.meta.url);
await dockerInstance.cp(localFile, "file");

Keywords

docker

FAQs

Package last updated on 21 Jan 2023

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