Module asyncdocker

This module implements an Docker Engine client based on Docker Remotet API. It's asynchronous (non-blocking) that it can be used to write web services for deploying swarm cluster and containers automatically on cloud environment. Of course, it can also be used to write any local deployment tools.

Docker cli vs asyncdocker

The docker cli example:

export DOCKER_HOST=127.0.0.1:2375
docker create --name hello --hostname 192.168.0.1 \
              ubuntu:14.04 /bin/bash -c 'echo hello'
docker start hello

And the equivalent asyncdocker example:

import asyncdocker, asyncdispatch, json

proc main() {.async.} =
  var docker = newAsyncDocker("127.0.0.1", Port(2375))
  var ret = await docker.create(image = "ubuntu:14.04",
                                name = "hello",
                                hostname = "192.168.0.1",
                                cmd = @["/bin/bash", "-c", "echo", "hello"])
  echo "Container Id: ", ret["Id"].getStr()
  await docker.start(name = "hello")
  docker.close()

waitFor main()

Simulate pull image

This example simulates the docker cli docker pull ubuntu:14.10 to download the image and print progress bars:

import asyncdocker, asyncdispatch, json

const
  hostname = "127.0.0.1"
  port = Port(2375)

proc pullCb(state: JsonNode): Future[bool] {.async.} =
  if state.hasKey("progress"):
    let current = state["progressDetail"]["current"].getNum()
    let total = state["progressDetail"]["total"].getNum()
    stdout.write("\r")
    stdout.write(state["id"].getStr())
    stdout.write(": ")
    stdout.write(state["status"].getStr())
    stdout.write(" ")
    stdout.write($current & "/" & $total)
    stdout.write(" ")
    stdout.write(state["progress"].getStr())
    if current == total:
      stdout.write("\n")
    stdout.flushFile()
  else:
    if state.hasKey("id"):
      stdout.write(state["id"].getStr())
      stdout.write(": ")
      stdout.write(state["status"].getStr())
      stdout.write("\n")
    else:
      stdout.write(state["status"].getStr())
      stdout.write("\n")

proc main() {.async.} =
  var docker = newAsyncDocker(hostname, port)
  await docker.pull(fromImage = "ubuntu", tag = "14.04", cb = pullCb)
  docker.close()

waitFor main()

output:

14.04: Pulling from library/ubuntu
b0efe5c05b4c: Pulling fs layer
0a1f1b169319: Pulling fs layer
1ceb0a3c7c48: Pulling fs layer
a3ed95caeb02: Pulling fs layer
a3ed95caeb02: Waiting
1ceb0a3c7c48: Downloading 682/682 [==================================================>]    682 B/682 B
1ceb0a3c7c48: Verifying Checksum
1ceb0a3c7c48: Download complete
a3ed95caeb02: Downloading 32/32 [==================================================>]     32 B/32 BB/77.8 kB
a3ed95caeb02: Verifying Checksum
a3ed95caeb02: Download complete
0a1f1b169319: Downloading 77797/77797 [==================================================>]  77.8 kB/77.8 kB
0a1f1b169319: Verifying Checksum
0a1f1b169319: Download complete
b0efe5c05b4c: Downloading 4848810/68321236 [===>                                               ] 4.849 MB/68.32 MB

Web service

You can write a web service with asynchttpserver:

import asyncdocker, asyncdispatch, asynchttpserver, json

var server = newAsyncHttpServer()

proc cb(req: Request) {.async.} =
  var docker = newAsyncDocker("127.0.0.1", Port(2375))
  var pass = true
  try:
    var ret = await docker.create(image = "ubuntu:14.04",
                                  name = "hello",
                                  hostname = "192.168.0.1",
                                  cmd = @["/bin/bash", "-c", "echo", "hello"])
    echo "Container Id: ", ret["Id"].getStr()
    await docker.start(name = "hello")
    await req.respond(Http201, "OK")
  except:
    pass = false
  if not pass:
    await req.respond(Http500, "Failure")
  docker.close()

waitFor server.serve(Port(8080), cb)

or with jester:

import asyncdocker, asyncdispatch, asynchttpserver, json, jester

routes:
  post "/containers/@name/run"
    var docker = newAsyncDocker("127.0.0.1", Port(2375))
    var pass = true
    try:
      var ret = await docker.create(image = "ubuntu:14.04",
                                    name = @"name",
                                    hostname = "192.168.0.1",
                                    cmd = @["/bin/bash", "-c", "echo", "hello"])
      echo "Container Id: ", ret["Id"].getStr()
      await docker.start(name = "hello")
      await req.respond(Http201, "OK")
    except:
      pass = false
    if not pass:
      await req.respond(Http500, "Failure")
    docker.close()

Stream support

Supports to stream responses from the docker daemon with attach, logs, execStart, etc. For example:

docker logs --follow hello
proc logsCb(): VndCallback =
  var i = 0
  proc cb(vnd: VndKind, data: string): Future[bool] {.async.} =
    if vnd == vndStdout:
      stdout.write("stdout: " & data)
    if vnd == vndStderr:
      stderr.write("stderr: " & data)
    echo i
    if i == 5:
     result = true ##   Close socket to stop receiving logs.
    inc(i)
  result = cb
await docker.logs("hello", follow = true, cb = logsCb())

Tls verify

Supports --tls and --tlsverify to protect docker daemon socket.

This requires the OpenSSL library, fortunately it's widely used and installed on many operating systems. Client will use SSL automatically if you give any of the functions a url with the https schema, for example: https://github.com/, you also have to compile with ssl defined like so: nim c -d:ssl ....

For --tls verification:

docker --host 127.0.0.1:2376 --tls --tlskey /home/docker/.docker/key.pem --tlscert /home/docker/.docker/cert.pem ps

equivalent to:

import asyncdocker, asyncdispatch, json, openssl

const
key = "/home/docker/.docker/key.pem" cert = "/home/docker/.docker/cert.pem"
proc main() {.async.}
var docker = newAsyncDocker("127.0.0.1", Port(2376), nil, key, cert, CVerifyNone) var containers = await docker.ps()

waitFor main()

For --tlsverify verification:

docker --host 127.0.0.1:2376 --tlsverify --tlscacert /home/docker/.docker/ca.pem --tlskey /home/docker/.docker/key.pem --tlscert /home/docker/.docker/cert.pem ps

equivalent to:

import asyncdocker, asyncdispatch, json, openssl

const
cacert = "/home/docker/.docker/ca.pem" key = "/home/docker/.docker/key.pem" cert = "/home/docker/.docker/cert.pem"
proc main() {.async.}
var docker = newAsyncDocker("127.0.0.1", Port(2376), cacert, key, cert, CVerifyPeer) var containers = await docker.ps()

waitFor main()

Swarm cluster support

The Docker Swarm API is mostly compatible with the Docker Remote API. see Docker Swarm Reference

Types

AsyncDocker = ref object
  scheme: string
  hostname: string
  port: string
  httpclient: AsyncHttpClient
Asynchronous docker client.   Source
ContainerStatus = enum
  statCreated, statRestarting, statRunning, statPaused, statExited
Enumeration of all container status.   Source
RestartPolicy = enum
  rpNo = "no", rpOnFailure = "on-failure", rpAlways = "always",
  rpUnlessStopped = "unless-stopped"
Enumeration of all restart policy for container.   Source
LogType = enum
  logNone = "none", logJsonFile = "json-file", logJournald = "journald",
  logGelf = "gelf", logAwslogs = "awslogs", logSplunk = "splunk"
Enumeration of all available log driver.   Source
DockerError = object of IOError
Requesting to docker daemon has an error.   Source
NotModifiedError = object of DockerError
Not modified from docker daemon, response status code is 304.   Source
BadParameterError = object of DockerError
Bad parameter from docker daemon, response status code is 400.   Source
ForbiddenError = object of DockerError
Forbidden from docker daemon, response status code is 403.   Source
NotFoundError = object of DockerError
Not found from docker daemon, response status code is 404.   Source
NotAcceptableError = object of DockerError
Not acceptable from docker daemon, response status code is 406.   Source
ConflictError = object of DockerError
Conflict from docker daemon, response status code is 409.   Source
ServerError = object of DockerError
Server error from docker daemon, response status code is 500.   Source
VndKind = enum
  vndStdin, vndStdout, vndStderr
  Source
VndCallback = proc (vnd: VndKind; data: string): Future[bool]
  Source
JsonCallback = proc (data: JsonNode): Future[bool]
  Source

Consts

dockerVersion = "1.23"
  Source
userAgent = "Nim Docker client/0.0.1 (1.23)"
  Source

Procs

proc newAsyncDocker(hostname: string; port: Port): AsyncDocker {.raises: [], tags: [].}
Creates a new AsyncDocker instance.   Source
proc close(c: AsyncDocker) {.raises: [SslError, OSError], tags: [].}
Closes the socket resource used by c.   Source
proc ps(c: AsyncDocker; all = false; size = false; limit = - 1; since = ""; before = "";
       exitedFilters: seq[int] = nil; statusFilters: seq[ContainerStatus] = nil;
       labelFilters: seq[string] = nil): Future[JsonNode] {.raises: [FutureError],
    tags: [RootEffect, ReadIOEffect].}

List containers. see Docker Reference

FutureError represents an exception, it may be BadParameterError, ServerError or DockerError.

Request parameters:

  • all - Show all containers. Only running containers are shown by default (i.e., this defaults to false).
  • size - Show the containers sizes.
  • limit - Show limit last created containers, include non-running ones.
  • since - Show only containers created since Id, include non-running ones.
  • before - Show only containers created before Id, include non-running ones.
  • exitedFilters - Filter containers with exit code.
  • statusFilters - Filter containers with status. Available status: created | restarting | running | paused | exited.
  • labelFilters - Filter containers with label.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {
    "Id": "8dfafdbc3a40",
    "Names":["/boring_feynman"],
    "Image": "ubuntu:latest",
    "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
    "Command": "echo 1",
    "Created": 1367854155,
    "Status": "Exit 0",
    "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    "Labels": {
      "com.example.vendor": "Acme",
      "com.example.license": "GPL",
      "com.example.version": "1.0"
    },
    "SizeRw": 12288,
    "SizeRootFs": 0
  },
  {
    "Id": "9cd87474be90",
    "Names":["/coolName"],
    "Image": "ubuntu:latest",
    "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
    "Command": "echo 222222",
    "Created": 1367854155,
    "Status": "Exit 0",
    "Ports": [],
    "Labels": {},
    "SizeRw": 12288,
    "SizeRootFs": 0
  },
  {
    "Id": "3176a2479c92",
    "Names":["/sleepy_dog"],
    "Image": "ubuntu:latest",
    "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
    "Command": "echo 3333333333333333",
    "Created": 1367854154,
    "Status": "Exit 0",
    "Ports":[],
    "Labels": {},
    "SizeRw":12288,
    "SizeRootFs":0
  },
  {
    "Id": "4cb07b47f9fb",
    "Names":["/running_cat"],
    "Image": "ubuntu:latest",
    "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
    "Command": "echo 444444444444444444444444444444444",
    "Created": 1367854152,
    "Status": "Exit 0",
    "Ports": [],
    "Labels": {},
    "SizeRw": 12288,
    "SizeRootFs": 0
  }
]

If you access the docker swarm api, the result will has new field Node added:

"Node": {
  "Id": "ODAI:IC6Q:MSBL:TPB5:HIEE:6IKC:VCAM:QRNH:PRGX:ERZT:OK46:PMFX",
  "Ip": "0.0.0.0",
  "Addr": "http://0.0.0.0:4243",
  "Name": "vagrant-ubuntu-saucy-64",
},

see Docker Reference of Swarm API

  Source
proc create(c: AsyncDocker; image: string; cmd, entrypoint: seq[string] = nil;
           name, hostname, domainname, user = "";
           attachStdin, attachStdout, attachStderr = true;
           tty, openStdin, stdinOnce = false;
           labels: seq[tuple[key, value: string]] = nil; workingDir, macAddress = "";
           stopSignal = "SIGTERM"; networkDisabled = false;
           env, exposedPorts, volumes, binds, links: seq[string] = nil;
           memory, memorySwap, memoryReservation, kernelMemory = 0;
           memorySwappiness = - 1; cpuShares, cpuPeriod, cpuQuota = 0;
           cpusetCpus, cpusetMems = ""; blkioWeight = 0;
           blkioWeightDevice: seq[tuple[path: string, weight: int]] = nil;
           blkioDeviceReadBps: seq[tuple[path: string, rate: int]] = nil;
           blkioDeviceWriteBps: seq[tuple[path: string, rate: int]] = nil;
           blkioDeviceReadIOps: seq[tuple[path: string, rate: int]] = nil;
           blkioDeviceWriteIOps: seq[tuple[path: string, rate: int]] = nil;
           oomKillDisable = false; oomScoreAdj = 0; networkMode = "bridge";
           portBindings: seq[tuple[port: string, hostPort: seq[string]]] = nil;
           publishAllPorts, privileged, readonlyRootfs = false;
           dns, dnsOptions, dnsSearch: seq[string] = nil;
           extraHosts, volumesFrom, capAdd, capDrop: seq[string] = nil; restartPolicy: tuple[
    name: RestartPolicy, maximumRetryCount: int] = (rpNo, 0);
           securityOpt: seq[string] = nil; cgroupParent, volumeDriver = ""; shmSize = 0;
           ulimits: seq[tuple[name: string, soft: int, hard: int]] = nil; devices: seq[
    tuple[pathOnHost, pathInContainer, cgroupPermissions: string]] = nil; logConfig: tuple[
    typ: LogType, config: seq[tuple[key, value: string]]] = (logJsonFile, nil)): Future[
    JsonNode] {.raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Create a container. see Docker Reference

FutureError represents an exception, it may be NotFoundError, NotAcceptableError, ServerError or DockerError.

Request parameters:

  • image - A string specifying the image name to use for the container.
  • cmd - Command to run specified as a string or an array of strings.
  • name - Assign the specified name or id to the container. Must match /?[a-zA-Z0-9_-]+.
  • hostname - A string value containing the hostname to use for the container.
  • domainname - A string value containing the domain name to use for the container.
  • user - A string value specifying the user inside the container.
  • attachStdin - Boolean value, attaches to stdin.
  • attachStdout - Boolean value, attaches to stdout.
  • attachStderr - Boolean value, attaches to stderr.
  • tty - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
  • openStdin - Boolean value, opens stdin.
  • stdinOnce - Boolean value, close stdin after the 1 attached client disconnects.
  • env - A list of environment variables in the form of @["VAR=value","VAR2=value2"].
  • entrypoint - Set the entry point for the container.
  • labels - Adds a map of labels to a container. To specify a map: {"key":"value", "key2":"value2"}.
  • workingDir - A string specifying the working directory for commands to run in.
  • stopSignal - Signal to stop a container as a string or unsigned integer. SIGTERM by default.
  • networkDisabled - Boolean value, when true disables networking for the container.
  • exposedPorts - Mapping ports in the form of: "@["<port>/<tcp|udp>"].
  • volumes - A list of volume that you want mount for this container.
  • binds - A list of volume bindings for this container. Each volume binding is a string in one of these forms:
    • container_path to create a new volume for the container.
    • host_path:container_path to bind-mount a host path into the container.
    • host_path:container_path:ro to make the bind-mount read-only inside the container.
  • links - A list of links for the container. Each link entry should be in the form of container_name:alias.
  • memory - Memory limit in bytes.
  • memorySwap - Total memory limit (memory + swap); set -1 to disable swap. You must use this with Memory and make the swap value larger than Memory.
  • memoryReservation - Memory soft limit in bytes.
  • kernelMemory - Kernel memory limit in bytes.
  • cpuShares - An integer value containing the container’s CPU Shares (ie. the relative weight vs other containers).
  • cpuPeriod - The length of a CPU period in microseconds.
  • cpuQuota - Microseconds of CPU time that the container can get in a CPU period.
  • cpuset - Deprecated please don’t use. Use CpusetCpus instead.
  • cpusetCpus - String value containing the cgroups CpusetCpus to use.
  • cpusetMems - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
  • blkioWeight - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
  • memorySwappiness - Tune a container’s memory swappiness behavior. Accepts an integer between 0 and 100.
  • blkioWeightDevice - Block IO weight (relative device weight) in the form of: @[("Path": "device_path", "Weight": weight)].
  • blkioDeviceReadBps - Limit read rate (bytes per second) from a device in the form of: @[("Path": "device_path", "Rate": rate)].
  • blkioDeviceWriteBps - Limit write rate (bytes per second) to a device in the form of: @[("Path": "device_path", "Rate": rate)].
  • blkioDeviceReadIOps - Limit read rate (IO per second) from a device in the form of: @[("Path": "device_path", "Rate": rate)].
  • blkioDeviceWriteIOps - Limit write rate (IO per second) to a device in the form of: @[("Path": "device_path", "Rate": rate)].
  • oomKillDisable - Boolean value, whether to disable OOM Killer for the container or not.
  • OomScoreAdj - An integer value containing the score given to the container in order to tune OOM killer preferences.
  • networkMode - Sets the networking mode for the container. Supported values are: bridge, host, and container:<name|id>.
  • portBindings - A map of exposed container ports.
  • publishAllPorts - Allocates a random host port for all of a container’s exposed ports.Specified as a boolean value.
  • privileged - Gives the container full access to the host. Specified as a boolean value.
  • readonlyRootfs - Mount the container’s root filesystem as read only. Specified as a boolean value.
  • dns - A list of DNS servers for the container to use.
  • dnsOptions - A list of DNS options.
  • dnsSearch - A list of DNS search domains
  • extraHosts - A list of hostnames/IP mappings to add to the container’s /etc/hosts file. Specified in the form ["hostname:IP"].
  • volumesFrom - A list of volumes to inherit from another container. Specified in the form <container name>[:<ro|rw>].
  • capAdd - A list of kernel capabilities to add to the container.
  • capdrop - A list of kernel capabilities to drop from the container.
  • restartPolicy - The behavior to apply when the container exits. The value is an object with a Name property of either "always" to always restart, "unless-stopped" to restart always except when user has manually stopped the container or "on-failure" to restart only when the container exit code is non-zero. If on-failure is used, MaximumRetryCount controls the number of times to retry before giving up. The default is not to restart. (optional) An ever increasingdelay (double the previous delay, starting at 100mS) is added before each restart to prevent flooding the server.
  • securityOpt - A list of string values to customize labels for MLS systems, such as SELinux.
  • cgroupParent - Path to cgroups under which the container’s cgroup is created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups are created if they do not already exist.
  • volumeDriver - Driver that this container users to mount volumes.
  • ShmSize - Size of /dev/shm in bytes. The size must be greater than 0. If omitted the system uses 64MB.
  • ulimits - A list of ulimits to set in the container, specified as ( "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> ).
  • devices - A list of devices to add to the container specified in the form ( "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw").
  • logConfig - Log configuration for the container, specified in the form ( "Type": "<driver_name>", "Config": {"key1": "val1"}). Available types: json-file, syslog, journald, gelf, awslogs, none. json-file logging driver.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Id":"e90e34656806",
  "Warnings":[]
}

Note: the official documentation of Mounts is invalid. Use Volumes or Binds to mount for your container. For example:

var ret = await docker.create(image = "ubuntu:14.10",
                              cmd = @["/bin/bash", "-c", "echo", "hello"],
                              exposedPorts = @["22/tcp"],
                              volumes = @["/tmp", "/data"],
                              portBindings = @[("5000", @["5000"])])
echo "Container Id: ", ret["Id"].getStr()

equivalent to:

docker create --expose 22/tcp \
              --volumes /tmp --volumes /store \
              --publish 5000:5000 \
              ubuntu:14.10 /bin/bash -c 'echo hello'

In the above example, docker engine will copy files from /tmp and /data to container volumes.

But following example does not copy (just mounting):

var ret = await docker.create(image = "ubuntu:14.10",
                              cmd = @["/bin/bash", "-c", "echo", "hello"],
                              exposedPorts = @["22/tcp"],
                              binds = @["/tmp:/tmp:ro", "/store:/data:rw"],
                              portBindings = @[("5000", @["5000"])])
echo "Container Id: ", ret["Id"].getStr()

equivalent to:

docker create --expose 22/tcp \
              --volumes /tmp:/tmp:ro --volumes /store:/data:rw \
              --publish 5000:5000 \
              ubuntu:14.10 /bin/bash -c 'echo hello'
  Source
proc inspect(c: AsyncDocker; name: string; size = false): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Return low-level information on the container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • size - Return container size information.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
 "AppArmorProfile": "",
 "Args": [
   "-c",
   "exit 9"
 ],
 "Config": {
   "AttachStderr": true,
   "AttachStdin": false,
   "AttachStdout": true,
   "Cmd": [
     "/bin/sh",
     "-c",
     "exit 9"
   ],
   "Domainname": "",
   "Entrypoint": null,
   "Env": [
     "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   ],
   "ExposedPorts": null,
   "Hostname": "ba033ac44011",
   "Image": "ubuntu",
   "Labels": {
     "com.example.vendor": "Acme",
     "com.example.license": "GPL",
     "com.example.version": "1.0"
   },
   "MacAddress": "",
   "NetworkDisabled": false,
   "OnBuild": null,
   "OpenStdin": false,
   "StdinOnce": false,
   "Tty": false,
   "User": "",
   "Volumes": null,
   "WorkingDir": "",
   "StopSignal": "SIGTERM"
 },
 "Created": "2015-01-06T15:47:31.485331387Z",
 "Driver": "devicemapper",
 "ExecDriver": "native-0.2",
 "ExecIDs": null,
 "HostConfig": {
   "Binds": null,
   "BlkioWeight": 0,
   "CapAdd": null,
   "CapDrop": null,
   "ContainerIDFile": "",
   "CpusetCpus": "",
   "CpusetMems": "",
   "CpuShares": 0,
   "CpuPeriod": 100000,
   "Devices": [],
   "Dns": null,
   "DnsOptions": null,
   "DnsSearch": null,
   "ExtraHosts": null,
   "IpcMode": "",
   "Links": null,
   "LxcConf": [],
   "Memory": 0,
   "MemorySwap": 0,
   "MemoryReservation": 0,
   "KernelMemory": 0,
   "OomKillDisable": false,
   "NetworkMode": "bridge",
   "PortBindings": {},
   "Privileged": false,
   "ReadonlyRootfs": false,
   "PublishAllPorts": false,
   "RestartPolicy": {
     "MaximumRetryCount": 2,
     "Name": "on-failure"
   },
   "LogConfig": {
     "Config": null,
     "Type": "json-file"
   },
   "SecurityOpt": null,
   "VolumesFrom": null,
   "Ulimits": [{}],
   "VolumeDriver": ""
 },
 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
 "MountLabel": "",
 "Name": "/boring_euclid",
 "NetworkSettings": {
   "Bridge": "",
   "SandboxID": "",
   "HairpinMode": false,
   "LinkLocalIPv6Address": "",
   "LinkLocalIPv6PrefixLen": 0,
   "Ports": null,
   "SandboxKey": "",
   "SecondaryIPAddresses": null,
   "SecondaryIPv6Addresses": null,
   "EndpointID": "",
   "Gateway": "",
   "GlobalIPv6Address": "",
   "GlobalIPv6PrefixLen": 0,
   "IPAddress": "",
   "IPPrefixLen": 0,
   "IPv6Gateway": "",
   "MacAddress": "",
   "Networks": {
     "bridge": {
       "EndpointID": "",
       "Gateway": "",
       "IPAddress": "",
       "IPPrefixLen": 0,
       "IPv6Gateway": "",
       "GlobalIPv6Address": "",
       "GlobalIPv6PrefixLen": 0,
       "MacAddress": ""
     }
   }
 },
 "Path": "/bin/sh",
 "ProcessLabel": "",
 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
 "RestartCount": 1,
 "State": {
   "Error": "",
   "ExitCode": 9,
   "FinishedAt": "2015-01-06T15:47:32.080254511Z",
   "OOMKilled": false,
   "Paused": false,
   "Pid": 0,
   "Restarting": false,
   "Running": true,
   "StartedAt": "2015-01-06T15:47:32.072697474Z",
   "Status": "running"
 },
 "Mounts": [
   {
     "Source": "/data",
     "Destination": "/data",
     "Mode": "ro,Z",
     "RW": false
   }
 ]
}
  Source
proc top(c: AsyncDocker; name: string; psArgs = "-ef"): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

List processes running inside the container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • psArgs - Ps arguments to use (e.g., aux).

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Titles": [
    "USER",
    "PID",
    "%CPU",
    "%MEM",
    "VSZ",
    "RSS",
    "TTY",
    "STAT",
    "START",
    "TIME",
    "COMMAND"
  ],
  "Processes": [
    ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
    ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
  ]
}
  Source
proc logs(c: AsyncDocker; name: string; stdout = true;
         stderr, follow, timestamps = false; since = 0; tail = "all"; cb: VndCallback): Future[
    void] {.raises: [FutureError], tags: [RootEffect].}

Get stdout and stderr logs from the container name (name or id). see Docker Reference

Note: This endpoint works only for containers with the json-file or journald logging drivers.

Note: one of stdout and stderr must be true.

FutureError represents an exception, it may be BadParameterError, NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • follow - Return stream. The response will output log for ever. If you want end to outputing, call close to close the socket used by AsyncDocker.
  • stdout - Show stdout log.
  • stderr - Show stderr log.
  • timestamps - Print timestamps for every log line.
  • since - UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered).
  • tail - Output specified number of lines at the end of logs: all or <number>.
  • cb - Handles the data from docker daemon. stream is one of stdin 0, stdout 1, stderr 2; log is the log data.

For example, if you start a container like this:

docker run --detach --name my_container ubuntu:14.04 \
           /bin/sh -c "while true; do echo hello world; sleep 1; done"

then, to get logs from this container like this:

var i = 0
await docker.logs("my_container", cb = proc(chunk: string) =
    echo "Log ", i, ": ", chunk
    inc(i))
echo "Complete ."

This will output:

Log 0: hello world
Log 1: hello world
Log 2: hello world
Complete .
  Source
proc changes(c: AsyncDocker; name: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Inspect changes on container’s filesystem. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {
    "Path": "/dev",
    "Kind": 0
  },
  {
    "Path": "/dev/kmsg",
    "Kind": 1
  },
  {
    "Path": "/test",
    "Kind": 1
  }
]

Values for Kind:

  • 0 - Modify
  • 1 - Add
  • 2 - Delete
  Source
proc exportContainer(c: AsyncDocker; name: string;
                    cb: proc (chunk: string): Future[bool]): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Export the contents of container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • cb - Handles the data from docker daemon in streaming.
  Source
proc stats(c: AsyncDocker; name: string; stream = false; cb: JsonCallback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Returns a live the container’s resource usage statistics. Note: this functionality currently only works when using the libcontainer exec-driver. Note: not support stream mode currently. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • stream - Pull stats once then disconnect.
  • cb - Pull stats once then disconnect. Corresponding to stream of docker remote api, handle response in streaming.

Example stat:

{
 "read" : "2015-01-08T22:57:31.547920715Z",
 "networks": {
   "eth0": {
     "rx_bytes": 5338,
     "rx_dropped": 0,
     "rx_errors": 0,
     "rx_packets": 36,
     "tx_bytes": 648,
     "tx_dropped": 0,
     "tx_errors": 0,
     "tx_packets": 8
   },
   "eth5": {
     "rx_bytes": 4641,
     "rx_dropped": 0,
     "rx_errors": 0,
     "rx_packets": 26,
     "tx_bytes": 690,
     "tx_dropped": 0,
     "tx_errors": 0,
     "tx_packets": 9
   }
 },
 "memory_stats" : {
   "stats" : {
     "total_pgmajfault" : 0,
     "cache" : 0,
     "mapped_file" : 0,
     "total_inactive_file" : 0,
     "pgpgout" : 414,
     "rss" : 6537216,
     "total_mapped_file" : 0,
     "writeback" : 0,
     "unevictable" : 0,
     "pgpgin" : 477,
     "total_unevictable" : 0,
     "pgmajfault" : 0,
     "total_rss" : 6537216,
     "total_rss_huge" : 6291456,
     "total_writeback" : 0,
     "total_inactive_anon" : 0,
     "rss_huge" : 6291456,
     "hierarchical_memory_limit" : "67108864",
     "total_pgfault" : 964,
     "total_active_file" : 0,
     "active_anon" : 6537216,
     "total_active_anon" : 6537216,
     "total_pgpgout" : 414,
     "total_cache" : 0,
     "inactive_anon" : 0,
     "active_file" : 0,
     "pgfault" : 964,
     "inactive_file" : 0,
     "total_pgpgin" : 477
   },
   "max_usage" : 6651904,
   "usage" : 6537216,
   "failcnt" : 0,
   "limit" : 67108864
 },
 "blkio_stats" : {},
 "cpu_stats" : {
   "cpu_usage" : {
     "percpu_usage" : [
       16970827,
       1839451,
       7107380,
       10571290
     ],
     "usage_in_usermode" : 10000000,
     "total_usage" : 36488948,
     "usage_in_kernelmode" : 20000000
   },
   "system_cpu_usage" : 20091722000000000,
   "throttling_data" : {}
 }
} 
  Source
proc resize(c: AsyncDocker; name: string; width: int; height: int): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Resize the TTY for container with name (name or id). The unit is number of characters. You must restart the container for the resize to take effect. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • width - New Width of tty session.
  • height - New height of tty session.
  Source
proc start(c: AsyncDocker; name: string; detachKeys: string = nil): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Start the container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • detachKeys - Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z @ ^ [ , _.
  Source
proc stop(c: AsyncDocker; name: string; time = 10): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Stop the container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • time - Number of seconds to wait before killing the container.
  Source
proc restart(c: AsyncDocker; name: string; time = 10): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Restart the container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • time - Number of seconds to wait before killing the container.

Restart the container name.

  Source
proc kill(c: AsyncDocker; name: string; signal = "SIGKILL"): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Kill the container name (name or id). see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • signal - Signal to send to the container: integer or string like SIGINT. When not set, SIGKILL is assumed and the call waits for the container to exit.
  Source
proc update(c: AsyncDocker; name: string;
           blkioWeight, cpuShares, cpuPeriod, cpuQuota = 0;
           cpusetCpus, cpusetMems = "";
           memory, memorySwap, memoryReservation, kernelMemory = 0): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Update resource configs of one or more containers. see Docker Reference

FutureError`` represents an exception, it may be ``BadParameterError``, ``NotFoundError``, ``ServerError`` or `DockerError.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Warnings": []
}
  Source
proc rename(c: AsyncDocker; name: string; newname: string): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Rename the container name to newname. see Docker Reference

FutureError`` represents an exception, it may be ``NotFoundError``, ``ConflictError``, ``ServerError`` or `DockerError.

## Request parameters:

  • name - The container name or id.
  • newname - The container new name or id.
  Source
proc pause(c: AsyncDocker; name: string): Future[void] {.raises: [FutureError],
    tags: [RootEffect].}

Pause the container name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  Source
proc unpause(c: AsyncDocker; name: string): Future[void] {.raises: [FutureError],
    tags: [RootEffect].}

Unpause the container name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  Source
proc attach(c: AsyncDocker; name: string; detachKeys: string = nil;
           logs, stream, stdin, stdout, stderr = false; cb: VndCallback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Attach to the container name. see Docker Reference

FutureError represents an exception, it may be BadParameterError, NotFoundError, ServerError or DockerError.

REquest parameters:

  • name - The container name or id.
  • logs - Return logs.
  • stream - Return stream.
  • stdin - If stream=true, attach to stdin.
  • stdout - If logs=true, return stdout log, if stream=true, attach to stdout.
  • stderr - If logs=true, return stderr log, if stream=true, attach to stderr.
  • cb - Handles the data from docker daemon.
  Source
proc wait(c: AsyncDocker; name: string): Future[JsonNode] {.raises: [FutureError],
    tags: [RootEffect, ReadIOEffect].}

Waiting for container name stops, then returns the exit code. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{"StatusCode": 0}
  Source
proc rm(c: AsyncDocker; name: string; volumes = false; force = false): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Remove the container name from the filesystem. see Docker Reference

FutureError represents an exception, it may be BadParameterError, NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • volumes - Remove the volumes associated to the container.
  • force - Kill then remove the container.
  Source
proc retrieveArchive(c: AsyncDocker; name: string; path: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Retrieving information about files and folders in the container name. see Docker Reference <https://docs.docker.com/engine/reference/api/docker_remote_api_v1.23/#retrieving-information-about-files-and-folders-in-a-container

FutureError represents an exception, it may be NotFoundError, BadParameterError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • path - Resource in the container’s filesystem to archive.

    If not an absolute path, it is relative to the container’s root directory. The resource specified by path must exist. To assert that the resource is expected to be a directory, path should end in / or /. (assuming a path separator of /). If path ends in /. then this indicates that only the contents of the path directory should be copied. A symlink is always resolved to its target.

    Note: It is not possible to copy certain system files such as resources under /proc, /sys, /dev, and mounts created by the user in the container.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "name": "home",
  "size": 4096,
  "mode": 2147484141,
  "mtime": "2014-04-11T06:12:14+08:00",
  "linkTarget": ""
}
  Source
proc getArchive(c: AsyncDocker; name: string; path: string;
               cb: proc (archive: string; stat: JsonNode): Future[bool]): Future[void] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Get an tar archive of a resource in the filesystem of container name. see Docker Reference <https://docs.docker.com/engine/reference/api/docker_remote_api_v1.23/#get-an-archive-of-a-filesystem-resource-in-a-container

FutureError represents an exception, it may be NotFoundError, BadParameterError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • path - Resource in the container’s filesystem to archive.
  • cb - Handles the archives from docker daemon.

    If not an absolute path, it is relative to the container’s root directory. The resource specified by path must exist. To assert that the resource is expected to be a directory, path should end in / or /. (assuming a path separator of /). If path ends in /. then this indicates that only the contents of the path directory should be copied. A symlink is always resolved to its target.

    Note: It is not possible to copy certain system files such as resources under /proc, /sys, /dev, and mounts created by the user in the container.

  • noOverwriteDirNonDir - If true then it will be an error if unpacking the
    given content would cause an existing directory to be replaced with a non-directory and vice versa.
  • cb - Handles the tar archive from docker daemon.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "name": "home",
  "size": 4096,
  "mode": 2147484141,
  "mtime": "2014-04-11T06:12:14+08:00",
  "linkTarget": ""
}
  Source
proc putArchive(c: AsyncDocker; name: string; path: string; archive: string;
               noOverwriteDirNonDir = false): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Upload a tar archive to be extracted to a path in the filesystem of container name. see Docker Reference <https://docs.docker.com/engine/reference/api/docker_remote_api_v1.23/#extract-an-archive-of-files-or-folders-to-a-directory-in-a-container

FutureError represents an exception, it may be NotFoundError, BadParameterError, ServerError or DockerError.

Request parameters:

  • name - The container name or id.
  • path - Resource in the container’s filesystem to archive.

    If not an absolute path, it is relative to the container’s root directory. The resource specified by path must exist. To assert that the resource is expected to be a directory, path should end in / or /. (assuming a path separator of /). If path ends in /. then this indicates that only the contents of the path directory should be copied. A symlink is always resolved to its target.

    Note: It is not possible to copy certain system files such as resources under /proc, /sys, /dev, and mounts created by the user in the container.

  • noOverwriteDirNonDir - If true then it will be an error if unpacking the
    given content would cause an existing directory to be replaced with a non-directory and vice versa.
  • archive - The tar archive.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "name": "home",
  "size": 4096,
  "mode": 2147484141,
  "mtime": "2014-04-11T06:12:14+08:00",
  "linkTarget": ""
}
  Source
proc images(c: AsyncDocker; all, digests = false; danglingFilters = false;
           labelFilters: seq[string] = nil; filter: string = nil): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

List Images. see Docker Reference

FutureError represents an exception, it may be DockerError.

Request parameters:

  • all - Show all images.
  • danglingFilters, labelFilters - Filters to process on the images list. Available filters:
    • dangling=true
    • label=key or label="key=value" of an image label
  • filter - Only return images with the specified name.

    For swarm api, use --filter node=<Node name> to show images of the specific node.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {
     "RepoTags": [
       "ubuntu:12.04",
       "ubuntu:precise",
       "ubuntu:latest"
     ],
     "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
     "Created": 1365714795,
     "Size": 131506275,
     "VirtualSize": 131506275,
     "Labels": {}
  },
  {
     "RepoTags": [
       "ubuntu:12.10",
       "ubuntu:quantal"
     ],
     "ParentId": "27cf784147099545",
     "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
     "Created": 1364102658,
     "Size": 24653,
     "VirtualSize": 180116135,
     "Labels": {
        "com.example.version": "v1"
     }
  }
]
  Source
proc build(c: AsyncDocker; tarball: string; dockerfile, t, remote: string = nil;
          q, nocache, pull, forcerm = false; rm = true; memory = 0; memswap = - 1;
          cpushares, cpusetcpus: string = nil; cpuperiod, cpuquota, shmsize = 0;
          buildargs: seq[tuple[key: string, value: string]] = nil;
          registryAuth: seq[tuple[url, username, password: string]] = nil;
          cb: JsonCallback): Future[void] {.raises: [FutureError], tags: [RootEffect].}

Build an image from a Dockerfile. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • tarball - The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
  • dockerfile - Path within the build context to the Dockerfile. This is ignored if remote is specified and points to an individual filename.
  • t - A name and optional tag to apply to the image in the name:tag format. If you omit the tag the default latest value is assumed. You can provide one or more t parameters.
  • remote - A Git repository URI or HTTP/HTTPS URI build source. If the URI specifies a filename, the file’s contents are placed into a file called Dockerfile.
  • q - Suppress verbose build output.
  • nocache - Do not use the cache when building the image.
  • pull - Attempt to pull the image even if an older image exists locally.
  • rm - Remove intermediate containers after a successful build (default behavior).
  • forcerm - Always remove intermediate containers (includes rm).
  • memory - Set memory limit for build.
  • memswap - Total memory (memory + swap), -1 to enable unlimited swap.
  • cpushares - CPU shares (relative weight).
  • cpusetcpus - CPUs in which to allow execution (e.g., 0-3, 0,1).
  • cpuperiod - The length of a CPU period in microseconds.
  • cpuquota - Microseconds of CPU time that the container can get in a CPU period.
  • buildargs - JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for command(s) run via the Dockerfile’s RUN instruction or for variable expansion in other Dockerfile instructions. This is not meant for passing secret values.
  • shmsize - Size of /dev/shm in bytes. The size must be greater than 0. If omitted the system uses 64MB.
  • registry - Registry auth config.
  Source
proc pull(c: AsyncDocker; fromImage: string; fromSrc, repo, tag: string = nil; registryAuth: tuple[
    username, password, email: string] = (nil, nil, nil); cb: JsonCallback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Create an image either by pulling it from the registry or by importing it. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • fromImage - Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed.
  • fromSrc - Source to import. The value may be a URL from which the image can be retrieved or - to read the image from the request body. This parameter may only be used when importing an image.
  • repo - Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image.
  • tag - Tag or digest.
  • registry - Registry auth config.
  • cb - Handle the response state.
  Source
proc inspectImage(c: AsyncDocker; name: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Return low-level information on the image name. see Docker Reference

## FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The image name or id.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
 "Id" : "85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
 "Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a",
 "Comment" : "",
 "Os" : "linux",
 "Architecture" : "amd64",
 "Parent" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
 "ContainerConfig" : {
   "Tty" : false,
   "Hostname" : "e611e15f9c9d",
   "Volumes" : null,
   "Domainname" : "",
   "AttachStdout" : false,
   "PublishService" : "",
   "AttachStdin" : false,
   "OpenStdin" : false,
   "StdinOnce" : false,
   "NetworkDisabled" : false,
   "OnBuild" : [],
   "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
   "User" : "",
   "WorkingDir" : "",
   "Entrypoint" : null,
   "MacAddress" : "",
   "AttachStderr" : false,
   "Labels" : {
     "com.example.license" : "GPL",
     "com.example.version" : "1.0",
     "com.example.vendor" : "Acme"
   },
   "Env" : [
     "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   ],
   "ExposedPorts" : null,
   "Cmd" : [
     "/bin/sh",
     "-c",
     "##  (nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0"
   ]
 },
 "DockerVersion" : "1.9.0-dev",
 "VirtualSize" : 188359297,
 "Size" : 0,
 "Author" : "",
 "Created" : "2015-09-10T08:30:53.26995814Z",
 "GraphDriver" : {
   "Name" : "aufs",
   "Data" : null
 },
 "RepoDigests" : [
   "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
 ],
 "RepoTags" : [
   "example:1.0",
   "example:latest",
   "example:stable"
 ],
 "Config" : {
   "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
   "NetworkDisabled" : false,
   "OnBuild" : [],
   "StdinOnce" : false,
   "PublishService" : "",
   "AttachStdin" : false,
   "OpenStdin" : false,
   "Domainname" : "",
   "AttachStdout" : false,
   "Tty" : false,
   "Hostname" : "e611e15f9c9d",
   "Volumes" : null,
   "Cmd" : [
     "/bin/bash"
   ],
   "ExposedPorts" : null,
   "Env" : [
     "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   ],
   "Labels" : {
     "com.example.vendor" : "Acme",
     "com.example.version" : "1.0",
     "com.example.license" : "GPL"
   },
   "Entrypoint" : null,
   "MacAddress" : "",
   "AttachStderr" : false,
   "WorkingDir" : "",
   "User" : ""
 }
}
  Source
proc history(c: AsyncDocker; name: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Return the history of the image name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The image name or id.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {
    "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
    "Created": 1398108230,
    "CreatedBy": "/bin/sh -c ##  (nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
    "Tags": [
      "ubuntu:lucid",
      "ubuntu:10.04"
    ],
    "Size": 182964289,
    "Comment": ""
  },
  {
    "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
    "Created": 1398108222,
    "CreatedBy": "/bin/sh -c ##  (nop) MAINTAINER Tianon Gravi <admwiggin@gmail.com> - mkimage-debootstrap.sh -i iproute,iputils-ping,ubuntu-minimal -t lucid.tar.xz lucid http://archive.ubuntu.com/ubuntu/",
    "Tags": null,
    "Size": 0,
    "Comment": ""
  },
  {
    "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
    "Created": 1371157430,
    "CreatedBy": "",
    "Tags": [
      "scratch12:latest",
      "scratch:latest"
    ],
    "Size": 0,
    "Comment": "Imported from -"
  }
]
  Source
proc push(c: AsyncDocker; name: string; tag: string = nil; registryAuth: tuple[
    username, password, email: string] = (nil, nil, nil); cb: JsonCallback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Push the image name on the registry. see Docker Reference

If you wish to push an image on to a private registry, that image must already have a tag into a repository which references that registry hostname and port. This repository name should then be used in the URL. This duplicates the command line’s flow.

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The image name or id.
  • tag - Show the containers sizes.
  • registryAuth - Login information.
  • cb - Handle the response state. State example:
    {"status": "Pushing..."}
    {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
    {"error": "Invalid..."}
    ...
  Source
proc tag(c: AsyncDocker; name, repo, tag: string; force = false): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Tag the image name into a repository. see Docker Reference

FutureError represents an exception, it may be BadParameterError, NotFoundError, ServerError, ConflictError`or `DockerError.

Request parameters:

  • name - The image name or id.
  • tag - The new tag name.
  • force - .
  Source
proc rmImage(c: AsyncDocker; name: string; force, noprune = false): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Remove the image name from the filesystem. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ConflictError, ServerError or DockerError.

Request paramters:

  • name - The image name or id.
  • force - Force removal of the image.
  • noprune - Do not delete untagged parents.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {"Untagged": "3e2f21a89f"},
  {"Deleted": "3e2f21a89f"},
  {"Deleted": "53b4f83ac9"}
]
  Source

Search for an image on Docker Hub. see Docker Reference

FutureError represents an exception, it may be ServerError, or DockerError.

Request parameters:

  • name - The term to search.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {
    "description": "",
    "is_official": false,
    "is_automated": false,
    "name": "wma55/u1210sshd",
    "star_count": 0
  },
  {
    "description": "",
    "is_official": false,
    "is_automated": false,
    "name": "jdswinbank/sshd",
    "star_count": 0
  },
  {
    "description": "",
    "is_official": false,
    "is_automated": false,
    "name": "vgauthier/sshd",
    "star_count": 0
  }
...
]
  Source
proc auth(c: AsyncDocker; username, password: string; email, serveraddress: string): Future[
    JsonNode] {.raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Check auth configuration. see Docker Reference

FutureError represents an exception, it may be ServerError, or DockerError.

  Source
proc info(c: AsyncDocker): Future[JsonNode] {.raises: [FutureError],
    tags: [RootEffect, ReadIOEffect].}

Display system-wide information. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
 "Containers": 11,
 "CpuCfsPeriod": true,
 "CpuCfsQuota": true,
 "Debug": false,
 "DiscoveryBackend": "etcd://localhost:2379",
 "DockerRootDir": "/var/lib/docker",
 "Driver": "btrfs",
 "DriverStatus": [[""]],
 "ExecutionDriver": "native-0.1",
 "ExperimentalBuild": false,
 "HttpProxy": "http://test:test@localhost:8080",
 "HttpsProxy": "https://test:test@localhost:8080",
 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
 "IPv4Forwarding": true,
 "Images": 16,
 "IndexServerAddress": "https://index.docker.io/v1/",
 "InitPath": "/usr/bin/docker",
 "InitSha1": "",
 "KernelVersion": "3.12.0-1-amd64",
 "Labels": [
   "storage=ssd"
 ],
 "MemTotal": 2099236864,
 "MemoryLimit": true,
 "NCPU": 1,
 "NEventsListener": 0,
 "NFd": 11,
 "NGoroutines": 21,
 "Name": "prod-server-42",
 "NoProxy": "9.81.1.160",
 "OomKillDisable": true,
 "OperatingSystem": "Boot2Docker",
 "RegistryConfig": {
   "IndexConfigs": {
     "docker.io": {
       "Mirrors": null,
       "Name": "docker.io",
       "Official": true,
       "Secure": true
     }
   },
   "InsecureRegistryCIDRs": [
     "127.0.0.0/8"
   ]
 },
 "SwapLimit": false,
 "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
 "ServerVersion": "1.9.0"
}  
  Source
proc version(c: AsyncDocker): Future[JsonNode] {.raises: [FutureError],
    tags: [RootEffect, ReadIOEffect].}

Display system-wide information. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
 "Version": "1.5.0",
 "Os": "linux",
 "KernelVersion": "3.18.5-tinycore64",
 "GoVersion": "go1.4.1",
 "GitCommit": "a8a31ef",
 "Arch": "amd64",
 "ApiVersion": "1.20",
 "Experimental": false
}
  Source
proc ping(c: AsyncDocker): Future[string] {.raises: [FutureError], tags: [RootEffect].}

Ping the docker server. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Result is a string. For example:

OK
  Source
proc commit(c: AsyncDocker; container: string; repo, tag: string; comment, author = "";
           pause = false; changes = ""; hostname, domainname, user = "";
           attachStdin, attachStdout, attachStderr, tty = false;
           openStdin, stdinOnce = false;
           env, cmd, volumes, exposedPorts: seq[string] = nil;
           labels: seq[tuple[key, value: string]] = nil; workingDir = "";
           networkDisabled = false): Future[JsonNode] {.raises: [FutureError],
    tags: [RootEffect, ReadIOEffect].}

Create a new image from a container’s changes. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • container - Source container.
  • repo - Repository.
  • tag - Tag.
  • comment - Commit message.
  • author - Author (e.g., John Hannibal Smith <hannibal@a-team.com>).
  • pause - Whether to pause the container before committing.
  • changes - Dockerfile instructions to apply while committing.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{"Id": "596069db4bf5"}
  Source
proc events(c: AsyncDocker; since, until = 0;
           filters: seq[tuple[key, value: string]] = nil; cb: JsonCallback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Get container events from docker, either in real time via streaming, or via polling (using since). see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • since - Timestamp used for polling.
  • until - Timestamp used for polling.
  • filters - The filters to process on the event list. Available filters:
    • container=<string> - container to filter
    • event=<string> - event to filter
    • image=<string> - image to filter
    • label=<string> - image and container label to filter
    • type=<string> -- either container or image or volume or network
    • volume=<string> -- volume to filter
    • network=<string> -- network to filter
  • cb - Handle the return events. Events example:
    {"status":"pull","id":"busybox:latest","time":1442421700,"timeNano":1442421700598988358}
    {"status":"create","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716853979870}
    {"status":"attach","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716894759198}
    {"status":"start","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716983607193}
  Source
proc get(c: AsyncDocker; name: string; cb: Callback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Get a tarball containing all images and metadata for the repository specified by name. see Docker Reference

If name is a specific name and tag (e.g. ubuntu:latest), then only that image (and its parents) are returned. If name is an image ID, similarly only that image (and its parents) are returned, but with the exclusion of the ‘repositories’ file in the tarball, as there were no image names referenced.

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • name - The image name and tag (e.g. ubuntu:latest) or image id.
  Source
proc get(c: AsyncDocker; names: seq[string]; cb: Callback): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Get a tarball containing all images and metadata for one or more repositories. see Docker Reference

For each value of the names parameter: if it is a specific name and tag (e.g. ubuntu:latest), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the ‘repositories’ file for this image ID.

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • names - The images name and tag (e.g. ubuntu:latest) or images id.
  Source
proc execCreate(c: AsyncDocker; name: string;
               attachStdin, attachStdout, attachStderr, tty = false; detachKeys = "";
               cmd: seq[string] = nil): Future[JsonNode] {.raises: [FutureError],
    tags: [RootEffect, ReadIOEffect].}

Sets up an exec instance in a running container name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ConflictError ServerError or DockerError.

Request patameters:

  • name - The container name or id.
  • attachStdin - Boolean value, attaches to stdin.
  • attachStdout - Boolean value, attaches to stdout.
  • attachStderr - Boolean value, attaches to stderr.
  • tty - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
  • detachKeys - Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.
  • cmd - Command to run.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Id": "f90e34656806",
  "Warnings":[]
}
  Source
proc execStart(c: AsyncDocker; name: string; detach, tty = false; cb: VndCallback): Future[
    void] {.raises: [FutureError], tags: [RootEffect].}

Starts a previously set up exec instance name. If detach is true, this API returns after starting the exec command. Otherwise, this API sets up an interactive session with the exec command. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ConflictError or DockerError.

Request parameters:

  • name - The exec instance id.
  • detach - Detach from the exec command.
  • tty - Boolean value to allocate a pseudo-TTY.
  Source
proc execResize(c: AsyncDocker; name: string; width, height: int): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Resizes the tty session used by the exec command id. The unit is number of characters. This API is valid only if tty was specified as part of creating and starting the exec command. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ConflictError or DockerError.

Request parameters:

  • width - Width of tty session.
  • height - Height of tty session.
  Source
proc execInspect(c: AsyncDocker; name: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Resizes the tty session used by the exec command id. The unit is number of characters. This API is valid only if tty was specified as part of creating and starting the exec command. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  "Running" : false,
  "ExitCode" : 2,
  "ProcessConfig" : {
    "privileged" : false,
    "user" : "",
    "tty" : false,
    "entrypoint" : "sh",
    "arguments" : [
      "-c",
      "exit 2"
    ]
  },
  "OpenStdin" : false,
  "OpenStderr" : false,
  "OpenStdout" : false,
  "Container" : {
    "State" : {
      "Status" : "running",
      "Running" : true,
      "Paused" : false,
      "Restarting" : false,
      "OOMKilled" : false,
      "Pid" : 3650,
      "ExitCode" : 0,
      "Error" : "",
      "StartedAt" : "2014-11-17T22:26:03.717657531Z",
      "FinishedAt" : "0001-01-01T00:00:00Z"
    },
    "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
    "Created" : "2014-11-17T22:26:03.626304998Z",
    "Path" : "date",
    "Args" : [],
    "Config" : {
      "Hostname" : "8f177a186b97",
      "Domainname" : "",
      "User" : "",
      "AttachStdin" : false,
      "AttachStdout" : false,
      "AttachStderr" : false,
      "ExposedPorts" : null,
      "Tty" : false,
      "OpenStdin" : false,
      "StdinOnce" : false,
      "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
      "Cmd" : [
        "date"
      ],
      "Image" : "ubuntu",
      "Volumes" : null,
      "WorkingDir" : "",
      "Entrypoint" : null,
      "NetworkDisabled" : false,
      "MacAddress" : "",
      "OnBuild" : null,
      "SecurityOpt" : null
    },
    "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": null,
        "SandboxKey": "",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "MacAddress": "",
        "Networks": {
            "bridge": {
                "EndpointID": "",
                "Gateway": "",
                "IPAddress": "",
                "IPPrefixLen": 0,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": ""
            }
        }
    },
    "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
    "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
    "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
    "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
    "Name" : "/test",
    "Driver" : "aufs",
    "ExecDriver" : "native-0.2",
    "MountLabel" : "",
    "ProcessLabel" : "",
    "AppArmorProfile" : "",
    "RestartCount" : 0,
    "Mounts" : []
  }
}
  Source
proc volumes(c: AsyncDocker; dangling = true): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

List volumes. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • dangling - Filters to process on the volumes list. There is one available filter: dangling=true

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Volumes": [
    {
      "Name": "tardis",
      "Driver": "local",
      "Mountpoint": "/var/lib/docker/volumes/tardis"
    }
  ]
}
  Source
proc createVolume(c: AsyncDocker; name: string; driver = "";
                 driverOpts: seq[tuple[key, value: string]] = nil): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Create a volume. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • Name - The new volume’s name. If not specified, Docker generates a name.
  • driver - Name of the volume driver to use. Defaults to local for the name.
  • driverOpts - A mapping of driver options and values. These options are passed directly to the driver and are driver specific.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Name": "tardis",
  "Driver": "local",
  "Mountpoint": "/var/lib/docker/volumes/tardis"
}
  • body - The JSON parameters. For example:
{
  "Name": "tardis"
}
  Source
proc inspectVolume(c: AsyncDocker; name: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Return low-level information on the volume name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The volume name or id.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Name": "tardis",
  "Driver": "local",
  "Mountpoint": "/var/lib/docker/volumes/tardis"
}
  Source
proc rmVolume(c: AsyncDocker; name: string): Future[void] {.raises: [FutureError],
    tags: [RootEffect].}

Instruct the driver to remove the volume name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ConflictError, ServerError or DockerError.

Request parameters:

  • name - The volume name or id.
  Source
proc networks(c: AsyncDocker;
             nameFilters, idFilters, typeFilters: seq[string] = nil): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

List networks. see Docker Reference

FutureError represents an exception, it may be ServerError or DockerError.

Request parameters:

  • filters - Filters to process on the networks list. Available filters: name=[network-names] , id=[network-ids].

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

[
  {
    "Name": "bridge",
    "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
    "Scope": "local",
    "Driver": "bridge",
    "IPAM": {
      "Driver": "default",
      "Config": [
        {
          "Subnet": "172.17.0.0/16"
        }
      ]
    },
    "Containers": {
      "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
        "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
        "MacAddress": "02:42:ac:11:00:02",
        "IPv4Address": "172.17.0.2/16",
        "IPv6Address": ""
      }
    },
    "Options": {
      "com.docker.network.bridge.default_bridge": "true",
      "com.docker.network.bridge.enable_icc": "true",
      "com.docker.network.bridge.enable_ip_masquerade": "true",
      "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
      "com.docker.network.bridge.name": "docker0",
      "com.docker.network.driver.mtu": "1500"
    }
  },
  {
    "Name": "none",
    "Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794",
    "Scope": "local",
    "Driver": "null",
    "IPAM": {
      "Driver": "default",
      "Config": []
    },
    "Containers": {},
    "Options": {}
  },
  {
    "Name": "host",
    "Id": "13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e",
    "Scope": "local",
    "Driver": "host",
    "IPAM": {
      "Driver": "default",
      "Config": []
    },
    "Containers": {},
    "Options": {}
  }
]
  Source
proc inspectNetwork(c: AsyncDocker; name: string): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Inspect network. see Docker Reference

FutureError represents an exception, it may be NotFoundError or DockerError.

Request parameters:

  • name - The network name or id.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Name": "bridge",
  "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
  "Scope": "local",
  "Driver": "bridge",
  "IPAM": {
    "Driver": "default",
    "Config": [
      {
        "Subnet": "172.17.0.0/16"
      }
    ]
  },
  "Containers": {
    "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
      "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
      "MacAddress": "02:42:ac:11:00:02",
      "IPv4Address": "172.17.0.2/16",
      "IPv6Address": ""
    }
  },
  "Options": {
    "com.docker.network.bridge.default_bridge": "true",
    "com.docker.network.bridge.enable_icc": "true",
    "com.docker.network.bridge.enable_ip_masquerade": "true",
    "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
    "com.docker.network.bridge.name": "docker0",
    "com.docker.network.driver.mtu": "1500"
  }
}
  Source
proc createNetwork(c: AsyncDocker; name: string; driver = "bridge"; ipamDriver = "";
    ipamConfig: seq[tuple[ipRange, subnet, gateway: string]] = nil;
                  options: seq[tuple[key: string, value: bool]] = nil): Future[JsonNode] {.
    raises: [FutureError], tags: [RootEffect, ReadIOEffect].}

Create a network. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The new network’s name. this is a mandatory field.
  • Driver - Name of the network driver to use. Defaults to bridge driver.
  • IPAM - Optional custom IP scheme for the network.
  • Options - Network specific options to be used by the drivers.
  • CheckDuplicate - Requests daemon to check for networks with same name.

Result is a JSON object, the internal members of which depends on the version of your docker engine. For example:

{
  "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30",
  "Warning": ""
}
  Source
proc connect(c: AsyncDocker; name, container: string; iPv4Address, iPv6Address = ""): Future[
    void] {.raises: [FutureError], tags: [RootEffect].}

Connects a container to a network. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

  • name - The new network’s name or id.
  • container - The container-id/name to be connected to the network.

FutureError represents an exception, it may be NotFoundError or DockerError.

Docs: https://docs.docker.com/engine/reference/api/docker_remote_api_v1.23/#connect-a-container-to-a-network

  Source
proc disconnect(c: AsyncDocker; name, container: string; force = false): Future[void] {.
    raises: [FutureError], tags: [RootEffect].}

Disconnects a container from a network. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The new network’s name or id.
  • container - The container-id/name to be connected to the network.
  • Force - Force the container to disconnect from a network.
  Source
proc rmNetWork(c: AsyncDocker; name: string): Future[void] {.raises: [FutureError],
    tags: [RootEffect].}

Instruct the driver to remove the network name. see Docker Reference

FutureError represents an exception, it may be NotFoundError, ServerError or DockerError.

Request parameters:

  • name - The new network’s name or id.
  Source