Modules@robinpath/docker
docker

@robinpath/docker

0.1.1Node.jsPublic

Docker container and image management using the system docker binary

Docker

Docker container and image management using the system docker binary

Package: @robinpath/docker | Category: Devops | Type: Integration

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the docker module when you need to:

  • List Docker containers -- Use docker.ps to perform this operation
  • List Docker images -- Use docker.images to perform this operation
  • Run a new container from an image -- Use docker.run to perform this operation
  • Stop a running container -- Use docker.stop to perform this operation
  • Start a stopped container -- Use docker.start to perform this operation

Quick Reference

FunctionDescriptionReturns
psList Docker containersobject
imagesList Docker imagesobject
runRun a new container from an imageobject
stopStop a running containerobject
startStart a stopped containerobject
rmRemove a containerobject
rmiRemove a Docker imageobject
logsFetch logs from a containerobject
execExecute a command inside a running containerobject
buildBuild a Docker image from a Dockerfileobject
pullPull a Docker image from a registryobject
pushPush a Docker image to a registryobject
inspectReturn low-level information on a container or imageobject
statsDisplay container resource usage statisticsobject
networkManage Docker networksobject
volumeManage Docker volumesobject

Functions

ps

List Docker containers

Module: docker | Returns: object -- API response.

docker.ps
ParameterTypeRequiredDescription
allbooleanNoShow all containers including stopped (default: true)
formatstringNoOutput format: json or table (default: json)

images

List Docker images

Module: docker | Returns: object -- API response.

docker.images
ParameterTypeRequiredDescription
formatstringNoOutput format: json or table (default: json)

run

Run a new container from an image

Module: docker | Returns: object -- API response.

docker.run
ParameterTypeRequiredDescription
imagestringYesImage name to run
optionsobjectNoRun options: detach, rm, name, ports[], env{}, volumes[], network, command

stop

Stop a running container

Module: docker | Returns: object -- API response.

docker.stop
ParameterTypeRequiredDescription
containerstringYesContainer ID or name
timeoutnumberNoSeconds to wait before killing

start

Start a stopped container

Module: docker | Returns: object -- API response.

docker.start
ParameterTypeRequiredDescription
containerstringYesContainer ID or name

rm

Remove a container

Module: docker | Returns: object -- API response.

docker.rm
ParameterTypeRequiredDescription
containerstringYesContainer ID or name
forcebooleanNoForce remove running container
volumesbooleanNoRemove associated volumes

rmi

Remove a Docker image

Module: docker | Returns: object -- API response.

docker.rmi
ParameterTypeRequiredDescription
imagestringYesImage ID or name
forcebooleanNoForce remove

logs

Fetch logs from a container

Module: docker | Returns: object -- API response.

docker.logs
ParameterTypeRequiredDescription
containerstringYesContainer ID or name
tailnumberNoNumber of lines from the end
followbooleanNoFollow log output

exec

Execute a command inside a running container

Module: docker | Returns: object -- API response.

docker.exec
ParameterTypeRequiredDescription
containerstringYesContainer ID or name
commandstringYesCommand to execute
interactivebooleanNoInteractive mode with TTY
workdirstringNoWorking directory inside container

build

Build a Docker image from a Dockerfile

Module: docker | Returns: object -- API response.

docker.build
ParameterTypeRequiredDescription
contextstringYesBuild context path
optionsobjectNoBuild options: tag, file, noCache, buildArgs{}

pull

Pull a Docker image from a registry

Module: docker | Returns: object -- API response.

docker.pull
ParameterTypeRequiredDescription
imagestringYesImage name with optional tag

push

Push a Docker image to a registry

Module: docker | Returns: object -- API response.

docker.push
ParameterTypeRequiredDescription
imagestringYesImage name with optional tag

inspect

Return low-level information on a container or image

Module: docker | Returns: object -- API response.

docker.inspect
ParameterTypeRequiredDescription
targetstringYesContainer or image ID/name
formatstringNoGo template format string

stats

Display container resource usage statistics

Module: docker | Returns: object -- API response.

docker.stats
ParameterTypeRequiredDescription
containerstringNoContainer ID or name (omit for all)

network

Manage Docker networks

Module: docker | Returns: object -- API response.

docker.network
ParameterTypeRequiredDescription
actionstringNoAction: ls, create, rm, inspect (default: ls)
namestringNoNetwork name
driverstringNoNetwork driver (for create)

volume

Manage Docker volumes

Module: docker | Returns: object -- API response.

docker.volume
ParameterTypeRequiredDescription
actionstringNoAction: ls, create, rm, inspect (default: ls)
namestringNoVolume name
driverstringNoVolume driver (for create)

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Ps and validate result"
do
  set $result as docker.ps
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Multi-step Docker workflow

Chain multiple docker operations together.

@desc "Ps, images, and more"
do
  set $r_ps as docker.ps
  set $r_images as docker.images
  set $r_run as docker.run
  print "All operations complete"
enddo

2. Safe ps with validation

Check results before proceeding.

@desc "Ps and validate result"
do
  set $result as docker.ps
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • git -- Git module for complementary functionality
  • github -- GitHub module for complementary functionality
  • gitlab -- GitLab module for complementary functionality
  • vercel -- Vercel module for complementary functionality
  • netlify -- Netlify module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/docker

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size5.3 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

devops