Struct bollard::DockerChain

source ·
pub struct DockerChain<C> { /* private fields */ }
Expand description

DockerChain

Retains the same API as the Docker Client, but consumes the instance and returns the instance as part of the response.

Examples

use bollard::Docker;
let docker = Docker::connect_with_http_defaults().unwrap();
docker.chain();

Implementations§


Kill Container

Kill a container. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::container::KillContainerOptions;

let options = Some(KillContainerOptions{
    signal: "SIGINT",
});

docker.chain().kill_container("postgres", options);

Remove Container

Remove a container. Consumes the instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::container::RemoveContainerOptions;

use std::default::Default;

let options = Some(RemoveContainerOptions{
    force: true,
    ..Default::default()
});

docker.chain().remove_container("hello-world", options);

Create Container

Prepares a container for a subsequent start operation. Consumes the instance.

Arguments
Returns
Examples
use bollard::container::{CreateContainerOptions, Config};

use std::default::Default;

let options = Some(CreateContainerOptions{
    name: "my-new-container",
});

let config = Config {
    image: Some("hello-world"),
    cmd: Some(vec!["/hello"]),
    ..Default::default()
};

docker.chain().create_container(options, config);

Start Container

Starts a container, after preparing it with the Create Container API. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples
use bollard::container::StartContainerOptions;

docker.chain().start_container("hello-world", None::<StartContainerOptions<String>>);

Stop Container

Stops a container. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples
use bollard::container::StopContainerOptions;

let options = Some(StopContainerOptions{
    t: 30,
});

docker.chain().stop_container("hello-world", options);

List Containers

Returns a list of containers. Consumes the client instance.

Arguments
Returns
Examples
use bollard::container::ListContainersOptions;

use std::collections::HashMap;
use std::default::Default;

let mut filters = HashMap::new();
filters.insert("health", vec!("unhealthy"));

let options = Some(ListContainersOptions{
    all: true,
    filters: filters,
    ..Default::default()
});

docker.chain().list_containers(options);

Wait Container

Wait for a container to stop. This is a non-blocking operation, the resulting stream will end when the container stops. Consumes the instance.

Arguments
Returns
Examples

use bollard::container::WaitContainerOptions;

let options = Some(WaitContainerOptions{
    condition: "not-running",
});

docker.chain().wait_container("hello-world", options);

Inspect Container

Inspect a container. Consumes the instance.

Arguments
Returns
Examples
use bollard::container::InspectContainerOptions;

let options = Some(InspectContainerOptions{
    size: false,
});

docker.chain().inspect_container("hello-world", options);

Restart Container

Restart a container. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::container::RestartContainerOptions;

let options = Some(RestartContainerOptions{
    t: 30,
});

docker.chain().restart_container("postgres", options);

Top Processes

List processes running inside a container. Consumes the client instance.

Arguments
  • Container name as string slice.
  • Optional Top Options struct.
Returns
Examples
use bollard::container::TopOptions;

let options = Some(TopOptions{
    ps_args: "aux",
});

docker.chain().top_processes("fnichol/uhttpd", options);

Logs

Get container logs. Consumes the client instance.

Arguments
Returns
Examples

use bollard::container::LogsOptions;

use std::default::Default;

let options = Some(LogsOptions{
    stdout: true,
    ..Default::default()
});

docker.chain().logs("hello-world", options);

Container Changes

Get changes on a container’s filesystem. Consumes the client instance.

Arguments
  • Container name as string slice.
Returns
  • A Tuple containing the original DockerChain instance, and an Option of Vector of Change structs, wrapped in a Future.
Examples

docker.chain().container_changes("hello-world");

Stats

Get container stats based on resource usage. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and a Stats struct, wrapped in a Stream.
Examples

use bollard::container::StatsOptions;

let options = Some(StatsOptions{
    stream: false,
});

docker.chain().stats("hello-world", options);

Update Container

Update a container. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::container::UpdateContainerOptions;
use std::default::Default;

let config = UpdateContainerOptions {
    memory: Some(314572800),
    memory_swap: Some(314572800),
    ..Default::default()
};

docker.chain().update_container("postgres", config);

Rename Container

Rename a container. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::container::RenameContainerOptions;

let required = RenameContainerOptions {
    name: "my_new_container_name"
};

docker.chain().rename_container("hello-world", required);

Pause Container

Use the cgroups freezer to suspend all processes in a container. Consumes the client instance.

Arguments
  • Container name as a string slice.
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

docker.chain().pause_container("postgres");

Unpause Container

Resume a container which has been paused. Consumes the client instance.

Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

docker.chain().unpause_container("postgres");

Prune Containers

Delete stopped containers. Consumes the client instance.

Arguments
Returns
Examples

use bollard::container::PruneContainersOptions;

use std::collections::HashMap;

let mut filters = HashMap::new();
filters.insert("until", vec!("10m"));

let options = Some(PruneContainersOptions {
  filters: filters
});

docker.chain().prune_containers(options);

Create Image

Create an image by either pulling it from a registry or importing it. Consumes the client instance.

Arguments
Returns
Examples
use bollard::image::CreateImageOptions;

use std::default::Default;

let options = Some(CreateImageOptions{
  from_image: "hello-world",
  ..Default::default()
});

docker.chain().create_image(options);

// do some other work while the image is pulled from the docker hub...
Unsupported
  • Import from tarball

Tag Image

Tag an image so that it becomes part of a repository. Consumes the instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::image::TagImageOptions;

let tag_options = Some(TagImageOptions {
    tag: "v1.0.1",
    ..Default::default()
});

docker.chain().tag_image("hello-world", tag_options);

Push Image

Push an image to a registry. Consumes the instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and the unit type (), wrapped in a Future.
Examples

use bollard::auth::DockerCredentials;
use bollard::image::PushImageOptions;

let push_options = Some(PushImageOptions {
    tag: "v1.0.1",
});

let credentials = Some(DockerCredentials {
    username: Some("Jack".to_string()),
    password: Some("myverysecretpassword".to_string()),
    email: Some("jack.smith@example.com".to_string()),
    serveraddress: Some("localhost:5000".to_string())
});

docker.push_image("hello-world", push_options, credentials);

Remove Image

Remove an image, along with any untagged parent images that were referenced by that image. Consumes the client instance.

Arguments
Returns
Examples

use bollard::image::RemoveImageOptions;

let remove_options = Some(RemoveImageOptions {
    force: true,
    ..Default::default()
});

docker.chain().remove_image("hello-world", remove_options);

Search Images

Search for an image on Docker Hub. Consumes the client instance.

Arguments
Returns
Examples

use bollard::image::SearchImagesOptions;
use std::default::Default;
use std::collections::HashMap;

let mut filters = HashMap::new();
filters.insert("until", "10m");

let search_options = SearchImagesOptions {
    term: "hello-world",
    filters: filters,
    ..Default::default()
};

docker.chain().search_images(search_options);

Inspect Image

Return low-level information about an image. Consumes the client instance.

Arguments
  • Image name as a string slice.
Returns
  • A Tuple containing the original DockerChain instance, and an Image, wrapped in a Future.
Examples

use std::default::Default;

docker.chain().inspect_image("hello-world");

List Images

Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image. Consumes the client instance.

Arguments
Returns
  • A Tuple containing the original DockerChain instance, and a Vector of APIImages, wrapped in a Future.
Examples
use bollard::image::ListImagesOptions;

use std::collections::HashMap;
use std::default::Default;

let mut filters = HashMap::new();
filters.insert("dangling", "true");

let options = Some(ListImagesOptions{
  all: true,
  filters: filters,
  ..Default::default()
});

docker.chain().list_images(options);

Image History

Return parent layers of an image. Consumes the client instance.

Arguments
  • Image name as a string slice.
Returns
Examples

docker.chain().image_history("hello-world");

Prune Images

Delete unused images. Consumes the client instance.

Arguments
Returns
Examples
use bollard::image::PruneImagesOptions;

use std::collections::HashMap;

let mut filters = HashMap::new();
filters.insert("until", "10m");

let options = Some(PruneImagesOptions {
  filters: filters
});

docker.chain().prune_images(options);

Commit Container

Create a new image from a container.

Arguments
Returns
Examples
use bollard::image::CommitContainerOptions;
use bollard::container::Config;

use std::default::Default;

let options = CommitContainerOptions{
    container: "my-running-container",
    pause: true,
    ..Default::default()
};

let config = Config::<String> {
    ..Default::default()
};

docker.chain().commit_container(options, config);

Version

Returns the version of Docker that is running and various information about the system that Docker is running on. Consumes the client instance.

Returns
  • A Tuple containing the original DockerChain instance, and a Version, wrapped in a Future.
Examples
docker.chain().version();

Ping

This is a dummy endpoint you can use to test if the server is accessible. Consumes the client instance.

Returns
  • A Tuple containing the original DockerChain instance, and a String, wrapped in a Future.
Examples

docker.chain().ping();

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.