https://github.com/jondotsoy/docker_child_process
Simple docker agent to NodeJS to run scripts in a container.
https://github.com/jondotsoy/docker_child_process
child-process docker
Last synced: about 2 months ago
JSON representation
Simple docker agent to NodeJS to run scripts in a container.
- Host: GitHub
- URL: https://github.com/jondotsoy/docker_child_process
- Owner: JonDotsoy
- License: mit
- Created: 2022-12-30T02:13:15.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2023-01-21T23:03:12.000Z (over 2 years ago)
- Last Synced: 2025-03-17T17:51:15.411Z (2 months ago)
- Topics: child-process, docker
- Language: TypeScript
- Homepage: http://npmjs.com/docker_child_process
- Size: 229 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# docker_child_process
A simple docker agent at NodeJS to run scripts in a container.
## Installation
Using [npm](https://npmjs.com):
```sh
$ npm install docker_child_process
```In NodeJS:
```ts
import { createInterface } from "docker_child_process";const dockerInstance = createInterface();
await dockerInstance.init();
await dockerInstance.exec(`echo ok`);
// # Docker: okconst { 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":"[email protected]","username":"jdalton"},"publisher":{"username":"bnjmnt4n","email":"[email protected]"},"maintainers":[{"username":"mathias","email":"[email protected]"},{"username":"jdalton","email":"[email protected]"},{"username":"bnjmnt4n","email":"[email protected]"}]} }
```## Copy files
To copy a file into the container, it's posible to call the `Instance.prototype.cp()` function.
```ts
const localFile = new URL("file", import.meta.url);
await dockerInstance.cp(localFile, "file");
```