1.1.1 • Published 5 years ago

@skypager/helpers-container v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Container Helper

The Container Helper is used to represent docker images which have been built by docker.

It represents all images for a particular docker container by its unique name. A docker container with a unique name can still have multiple tags, and image ids, based on how many times it has been built and changed.

If you modify a docker container, it will have a new imageId / hash value.

Usage

import runtime from '@skypager/node'
import * as ContainerHelper from '@skypager/helpers-container'

runtime.use(ContainerHelper)

This will create a registry of containers on runtime.containers and a factory function cor creating instances of containers by its unique name.

Discovering Containers

You can discover which containers have already been built on the system by running

runtime.containers.discover()

And see which ones have been found

runtime.containers.available

And then create an instance of the Helper object to represent that container

runtime.container('node')

What can you do with it?

You can see the various docker configuration values

const { env, workingDir, entryPoint, cmd } = runtime.container('node')

You can see all available tags, all the containerIds and container names for any running instances of the image

const { isRunning, tags, containerIds, imageIds } = runtime.container('node')

You can start an instance of the image

runtime.container('node').start()

Or execute a command in a running instance of the container

runtime.container('node').exec('ls -al')