Manage Docker from Dart
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Dart client for the Docker remote API

Star this Repo Pub Package Build Status Coverage Status

See Docker Remote API v1.19 for more details.

This package provides a typed interface to the Docker REST API and deserializes JSON response to Dart classes.

The intention is to make it easy to automate Docker related tasks from Grinder or other scripts. This package also makes it easy to build a dashboard for the Docker service.


See example below or the unit tests.

Ensure you have Docker listening on a TCP port (for more details see Bind Docker to another host/port or a Unix socket), because Dart currently can't communicate using Unix sockets (see Dart Issue 21403 - Support Unix Sockets in dart:io for details).

Supported commands


  • attach (Attach to a container)
  • changes (Changes to a containers file system)
  • container (Inspect a container)
  • containers (List containers)
  • copy (Copy files or folders from a container)
  • create (Create a container)
  • export (Export a container)
  • kill (Kill a container)
  • logs (Get container logs)
  • pause (Pause a container)
  • top (List processes running inside a container)
  • rename (Rename a container)
  • remove (Remove a container)
  • resize (Resize a container TTY)
  • restart (Restart a container)
  • start (Start a container)
  • stats (Get container stats based on resource usage)
  • stop (Stop a container)
  • unpause (Unpause a container)
  • wait (Wait a container)


  • build (missing test) (Build image from a Dockerfile)
  • create (Create an image)
  • image (Inspect an image)
  • images (List images)
  • history (Get the history of an image)
  • push (missing test) (Push an image into a repository)
  • tag (Tag an image into a repository)
  • remove (Remove an image)
  • search (Search images)


  • auth (Check auth configuration)
  • commit (Create a new image from a containers changes)
  • events (Monitor Dockers events)
  • exec create (Set up an exec instance)
  • exec inspect (Inspect an exec command)
  • exec resize (missing test) (Resize the tty session)
  • exec start (Start an exec instance)
  • get (Get a tarball containing all images in a repository)
  • get all (missing test) (Get a tarball containing all images)
  • info (Display system-wide information)
  • load (missing test) (Load a tarball with a set of images and tags into Docker)
  • ping (Ping the docker server)
  • version (Show the Docker version information)


I'm not a Docker specialist. If something isn't working as expected or you are missing a feature just create a bug report in the GitHub repo or even better, create a pull request.


  • container attachWs (Attach to a container using websocket)
  • image build (missing test) (Build image from a Dockerfile)
  • image push (missing test) (Push an image into a repository)
  • misc get all (missing test) (Get a tarball containing all images)
  • misc load (missing test) (Load a tarball with a set of images and tags into Docker)
  • exec resize (missing test) (Resize the tty session)


Run docker pull busybox before runing the example to ensure the used image is available.

library bwu_docker.example.images;

import 'dart:io' as io;
import 'package:http/http.dart' as http;
import 'package:bwu_docker/bwu_docker.dart';

main() async {
  // initialize the connection to the Docker service
  final conn = new DockerConnection(
      new http.Client());
  await conn.init();

  // create a container from an image
  CreateResponse created = await conn.createContainer(
      new CreateContainerRequest()
    ..image = 'busybox'
    ..hostConfig.logConfig = {'Type': 'json-file'});

  // start the container
  await conn.start(created.container);

  // load the list of containers
  Iterable<Container> containers = await conn.containers();

  // investigate response
  var found = containers.firstWhere((c) => ==;
  print('found: ${}, name: ${found.names.join(', ')}\n');

  containers.forEach((Container c) {
        'Container ID: ${}, names: ${c.names.join(', ')}, status: ${c.status}');

  // clean up
  await conn.stop(created.container);
  await conn.removeContainer(created.container);

For more examples check out the unit tests.

Also check out the BWU Docker wiki pages.