A lib and command line utility to help with manipulating the Docker CLI. Built to work nicely with buildGoggles.
Primary use case (for now) is to read the .buildinfo.json
file and tag a Docker image with all the tags found. Yeah, it is simple, but it turns out this is an immense pain in the neck to pull off in most CIs/bash and pretty simple in Node.
A local Docker registry for the push integration tests.
Start local registry
./setup-registry.sh
Tear down local registry
./kill-registry.sh
All calls return promises which resolve or reject with the output of the command.
var pequod = require( "pequod" )( false, logger ); // sets sudo to false
- logger - optional log call that accepts string output from Docker process
options
is a hash of fields:
working
- default: "./"file
- default: "Dockerfile"cacheFrom
- provide a image specification for Docker to build off ofargs
- a hash of key/values used to populateARG
s defined in the Dockerfile
pequod
.build( "test-image" )
.then( function( list ) {
// the list of console lines output
} );
Creates a container from an image with the following available options:
name
- a string providing a friendly nameentrypoint
- the entrypoint to use for the containerenv
- a hash of key/value pairs to use as environment variableslinks
- an array of named container links to other containersports
- a hash of key/value pairs to use for host -> container port mappingsvolumes
- a hash of host paths to mount to to container paths
Exports a container either as a tarball or to a pipe with the following options:
output
- the path to the tarball file to save the container's state in
If the output
option is left off, the call will resolve the output stream which can then be piped to something else.
Imports either a stream or a tarball into a new, single image layer. If source
is a path to a file, it will use the tarball, if source
is set to the string "pipe"
then it will expect the option pipe
to be set to the stream containing the image.
Options:
changes
- an array of legal Docker image changes to make to the image during import. See [ https://docs.docker.com/engine/reference/commandline/import/#extended-description](Docker's documentation) for details.message
- a custom commit message to set when creating the new layer
pequod
.info()
.then( function( list ) {
// the list of console lines output
} );
pequod.inspect('repo/image:tag')
.then( function( data ) {
// process data
} );
Data structure:
{
Id: 'sha256:[sha]',
RepoTags: [
'repo/image:tag'
],
RepoDigests: [
'repo/image@sha256:[sha]'
],
Parent: '',
Comment: '',
Created: 'ISO timestamp',
Container: 'attached container id',
ContainerConfig: {
Hostname: '',
Domainname: '',
User: '',
AttachStdin: Boolean,
AttachStdout: Boolean,
AttachStderr: Boolean,
Tty: Boolean,
OpenStdin: Boolean,
StdinOnce: Boolean,
Env: [
'ENV=value'
],
Cmd: [
'/bin/sh',
'-c',
'#(nop) ',
'CMD [\"/bin/sh\" \"-c\" \"./kick.sh\"]'
],
ArgsEscaped: Boolean,
Image: 'sha256:[sha]',
Volumes: [] | null,
WorkingDir: '/',
Entrypoint: '' | null,
OnBuild: [],
Labels: {}
},
DockerVersion: '',
Author: '',
Config: {
Hostname: '',
Domainname: '',
User: '',
AttachStdin: Boolean,
AttachStdout: Boolean,
AttachStderr: Boolean,
Tty: Boolean,
OpenStdin: Boolean,
StdinOnce: Boolean,
Env: [
'ENV=value'
],
Cmd: [
'/bin/sh',
'-c',
'./kick.sh'
],
ArgsEscaped: Boolean,
Image: 'sha256:[sha]',
Volumes: [] | null,
WorkingDir: '/',
Entrypoint: '' | null,
OnBuild: [],
Labels: null
},
Architecture: 'amd64',
Os: 'linux',
Size: #,
VirtualSize: #,
GraphDriver: {
Data: {
LowerDir: '/var/lib/docker/overlay2...',
MergedDir: '',
UpperDir: '',
WorkDir: ''
},
Name: 'overlay2'
},
RootFS: {
Type: 'layers',
Layers: [
'sha256:[sha]',
...
]
},
Metadata: {
LastTagTime: 'ISO '
}
}
server
is optional and defaults to the official Docker hub.
pequod
.login( '$DOCKER_USER', '$DOCKER_PASS' )
.then( function( list ) {
// the list of console lines output
} );
Pulls an image.
pequod
.pull( 'test-image' )
.then( function( list ) {
// the list of console lines output
} );
Pushes the image.
pequod
.push( 'test-image' )
.then( function( list ) {
// the list of console lines output
} );
Pushes all tags specified in ./.buildinfo.json
.
pequod.pushTags('test-image');
Tags the source image with the specified target tag.
pequod
.tag( 'test-image', 'test-image:1.1' )
.then( function( list ) {
// the list of console lines output
} );
Tags the source image according to a ./.buildinfo.json
.
pequod.tagImage('test-image');
Removes the container from the local daemon by name or id.
pequod
.removeContainer('')
Removes the image (or untags it).
pequod
.removeImage( 'test-image' )
.then( function( list ) {
// the list of console lines output
} );
pequod
.version()
.then( function( list ) {
// the list of console lines output
} );
There's more to it than this, but give this is really the primary reason for its existence, I'm gonna keep things boring for now √