@amazing-kit/docker
v1.0.6
Published
Run docker commands in node.js (not all commands are supported yet)
Downloads
14
Readme
@amazing-kit/docker
Run docker commands from nodejs
- run
- stop
- ps
Install
pnpm add @amazing-kit/docker
// ESModule only
import docker from "@amazing-kit/docker"
Get docker containers
const all_containers = await docker.ps({ all: true })
// get container data in JSON format
Run a new docker container
await docker.run("image_name", {
// all options are optional
name: "container_name",
ports: [
{ host: 8080, container: 80 }
],
env: [
{ name: "ENV_NAME", value: "ENV_VALUE"}
],
volumes: [
{ source: "/host/path", container: "/container/path", readonly: true }
],
auto_remove: true, // default false
daemon: true, // default false
})
Stop a docker container
await docker.stop("container_name", { forceKillAfter: 1000 })