2.0.12 • Published 11 months ago
run-container v2.0.12
run-container
run a docker container in nodejs
runs a container using dockerode, bootstrapping the pull & start processes, whilst also exposing a compact function to simplify docker's and dockerode's otherwise complex APIs
usage
import { run, runSimple } from "run-container";
// runSimple, minimal example
const container = await runSimple({ image: "postgres" }); // => Dockerode.Container instance
await container.remove({ force: true });
// runSimple, rich example
await runSimple({
autoRemove: true,
bindMounts: { "/path/to/host/file.sh": "/path/to/container/file.sh" },
cmd: ["bash", "/path/to/container/file.sh"],
env: { KEY: "VALUE" },
image: "bash",
name: "script-fun",
ports: { "4000": "4000" }, // tcp ports only. otherwise, use `run`
});
await container.wait();
await container.remove();
// run
// exposes Dockerodes.ContainerCreateOptions full API,
// which directly reflects the docker engine API!
// https://docs.docker.com/engine/api/latest/
const container = await run({
Image: "postgres",
ExposedPorts: {
"5432/tcp": {},
},
HostConfig: {
AutoRemove: true,
PortBindings: { "5432/tcp": [{ HostPort: "40000" }] },
},
});
// ... do work
await container.remove({ force: true });
see the exported typescript typings in the docs folder, or check out the tiny source.
2.0.11
11 months ago
2.0.12
11 months ago
2.0.10
1 year ago
2.0.9
1 year ago
2.0.8
1 year ago
2.0.7
1 year ago
2.0.5
1 year ago
2.0.6
1 year ago
2.0.4
1 year ago
2.0.3
2 years ago
2.0.2
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.2.4
2 years ago
1.2.3
4 years ago
1.2.2
5 years ago
1.2.0
5 years ago
1.2.1
5 years ago
1.1.2
5 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago