pub struct Docker<C> { /* private fields */ }
Expand description
Docker
The main interface for calling the Docker API. Construct a new Docker instance using one of the connect methods:
Implementations§
source§impl<C> Docker<C>where
C: Connect + Sync + 'static,
impl<C> Docker<C>where
C: Connect + Sync + 'static,
sourcepub fn list_containers<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = Vec<APIContainers>, Error = Error>where
T: ListContainersQueryParams<K, String>,
K: AsRef<str>,
pub fn list_containers<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = Vec<APIContainers>, Error = Error>where
T: ListContainersQueryParams<K, String>,
K: AsRef<str>,
List Containers
Returns a list of containers.
Arguments
- Optional ListContainersOptions struct.
Returns
- Vector of APIContainers, wrapped in a Future.
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.list_containers(options);
sourcepub fn create_container<T, K, V, Z>(
&self,
options: Option<T>,
config: Config<Z>
) -> impl Future<Item = CreateContainerResults, Error = Error>where
T: CreateContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: AsRef<str> + Eq + Hash + Serialize,
pub fn create_container<T, K, V, Z>(
&self,
options: Option<T>,
config: Config<Z>
) -> impl Future<Item = CreateContainerResults, Error = Error>where
T: CreateContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: AsRef<str> + Eq + Hash + Serialize,
Create Container
Prepares a container for a subsequent start operation.
Arguments
- Optional Create Container Options struct.
- Container Config struct.
Returns
- Create Container Results, wrapped in a Future.
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.create_container(options, config);
sourcepub fn start_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: StartContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn start_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: StartContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Start Container
Starts a container, after preparing it with the Create Container API.
Arguments
- Container name as a string slice.
- Optional Start Container Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::StartContainerOptions;
docker.start_container("hello-world", None::<StartContainerOptions<String>>);
sourcepub fn stop_container<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: StopContainerQueryParams<K>,
K: AsRef<str>,
pub fn stop_container<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: StopContainerQueryParams<K>,
K: AsRef<str>,
Stop Container
Stops a container.
Arguments
- Container name as string slice.
- Optional Stop Container Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::StopContainerOptions;
let options = Some(StopContainerOptions{
t: 30,
});
docker.stop_container("hello-world", options);
sourcepub fn remove_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: RemoveContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn remove_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: RemoveContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Remove Container
Remove a container.
Arguments
- Container name as a string slice.
- Optional Remove Container Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::RemoveContainerOptions;
use std::default::Default;
let options = Some(RemoveContainerOptions{
force: true,
..Default::default()
});
docker.remove_container("hello-world", options);
sourcepub fn wait_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = WaitContainerResults, Error = Error>where
T: WaitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn wait_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = WaitContainerResults, Error = Error>where
T: WaitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Wait Container
Wait for a container to stop. This is a non-blocking operation, the resulting stream will end when the container stops.
Arguments
- Container name as string slice.
- Optional Wait Container Options struct.
Returns
- Wait Container Results, wrapped in a Stream.
Examples
use bollard::container::WaitContainerOptions;
let options = Some(WaitContainerOptions{
condition: "not-running",
});
docker.wait_container("hello-world", options);
sourcepub fn restart_container<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: RestartContainerQueryParams<K>,
K: AsRef<str>,
pub fn restart_container<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: RestartContainerQueryParams<K>,
K: AsRef<str>,
Restart Container
Restart a container.
Arguments
- Container name as string slice.
- Optional Restart Container Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::RestartContainerOptions;
let options = Some(RestartContainerOptions{
t: 30,
});
docker.restart_container("postgres", options);
sourcepub fn inspect_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = Container, Error = Error>where
T: InspectContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn inspect_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = Container, Error = Error>where
T: InspectContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Inspect Container
Inspect a container.
Arguments
- Container name as a string slice.
- Optional Inspect Container Options struct.
Returns
- Container, wrapped in a Future.
Examples
use bollard::container::InspectContainerOptions;
let options = Some(InspectContainerOptions{
size: false,
});
docker.inspect_container("hello-world", options);
sourcepub fn top_processes<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = TopResult, Error = Error>where
T: TopQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn top_processes<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = TopResult, Error = Error>where
T: TopQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Top Processes
List processes running inside a container.
Arguments
- Container name as string slice.
- Optional Top Options struct.
Returns
- TopResult, wrapped in a Future.
Examples
use bollard::container::TopOptions;
let options = Some(TopOptions{
ps_args: "aux",
});
docker.top_processes("fnichol/uhttpd", options);
sourcepub fn logs<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = LogOutput, Error = Error>where
T: LogsQueryParams<K>,
K: AsRef<str>,
pub fn logs<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = LogOutput, Error = Error>where
T: LogsQueryParams<K>,
K: AsRef<str>,
Logs
Get container logs.
Arguments
- Container name as string slice.
- Optional Logs Options struct.
Returns
- Log Output enum, wrapped in a Stream.
Examples
use bollard::container::LogsOptions;
use std::default::Default;
let options = Some(LogsOptions{
stdout: true,
..Default::default()
});
docker.logs("hello-world", options);
sourcepub fn container_changes(
&self,
container_name: &str
) -> impl Future<Item = Option<Vec<Change>>, Error = Error>
pub fn container_changes(
&self,
container_name: &str
) -> impl Future<Item = Option<Vec<Change>>, Error = Error>
Container Changes
Get changes on a container’s filesystem.
Arguments
- Container name as string slice.
Returns
- An Option of Vector of Change structs, wrapped in a Future.
Examples
docker.container_changes("hello-world");
sourcepub fn stats<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Stats, Error = Error>where
T: StatsQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn stats<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Stats, Error = Error>where
T: StatsQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Stats
Get container stats based on resource usage.
Arguments
- Container name as string slice.
- Optional Stats Options struct.
Returns
- Stats struct, wrapped in a Stream.
Examples
use bollard::container::StatsOptions;
let options = Some(StatsOptions{
stream: false,
});
docker.stats("hello-world", options);
sourcepub fn kill_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: KillContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn kill_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: KillContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Kill Container
Kill a container.
Arguments
- Container name as string slice.
- Optional Kill Container Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::KillContainerOptions;
let options = Some(KillContainerOptions{
signal: "SIGINT",
});
docker.kill_container("postgres", options);
sourcepub fn update_container(
&self,
container_name: &str,
config: UpdateContainerOptions
) -> impl Future<Item = (), Error = Error>
pub fn update_container(
&self,
container_name: &str,
config: UpdateContainerOptions
) -> impl Future<Item = (), Error = Error>
Update Container
Update a container.
Arguments
- Container name as string slice.
- Update Container Options struct.
Returns
- 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.update_container("postgres", config);
sourcepub fn rename_container<T, K, V>(
&self,
container_name: &str,
options: T
) -> impl Future<Item = (), Error = Error>where
T: RenameContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn rename_container<T, K, V>(
&self,
container_name: &str,
options: T
) -> impl Future<Item = (), Error = Error>where
T: RenameContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Rename Container
Rename a container.
Arguments
- Container name as string slice.
- Rename Container Options struct
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::RenameContainerOptions;
let required = RenameContainerOptions {
name: "my_new_container_name"
};
docker.rename_container("hello-world", required);
sourcepub fn pause_container(
&self,
container_name: &str
) -> impl Future<Item = (), Error = Error>
pub fn pause_container(
&self,
container_name: &str
) -> impl Future<Item = (), Error = Error>
Pause Container
Use the cgroups freezer to suspend all processes in a container.
Arguments
- Container name as a string slice.
Returns
- unit type
()
, wrapped in a Future.
Examples
docker.pause_container("postgres");
sourcepub fn unpause_container(
&self,
container_name: &str
) -> impl Future<Item = (), Error = Error>
pub fn unpause_container(
&self,
container_name: &str
) -> impl Future<Item = (), Error = Error>
Unpause Container
Resume a container which has been paused.
Arguments
- Container name as a string slice.
Returns
- unit type
()
, wrapped in a Future.
Examples
docker.unpause_container("postgres");
sourcepub fn prune_containers<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = PruneContainersResults, Error = Error>where
T: PruneContainersQueryParams<K>,
K: AsRef<str> + Eq + Hash,
pub fn prune_containers<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = PruneContainersResults, Error = Error>where
T: PruneContainersQueryParams<K>,
K: AsRef<str> + Eq + Hash,
Prune Containers
Delete stopped containers.
Arguments
- Optional Prune Containers Options struct.
Returns
- PruneContainersResults struct, wrapped in a Future.
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.prune_containers(options);
source§impl Docker<HttpConnector>
impl Docker<HttpConnector>
A Docker implementation typed to connect to an unsecure Http connection.
sourcepub fn connect_with_http_defaults() -> Result<Docker<impl Connect>, Error>
pub fn connect_with_http_defaults() -> Result<Docker<impl Connect>, Error>
Connect using unsecured HTTP using defaults that are signalled by environment variables.
Defaults
- The connection url is sourced from the
DOCKER_HOST
environment variable, and defaults tolocalhost:2375
. - The number of threads used for the HTTP connection pool defaults to 1.
- The request timeout defaults to 2 minutes.
Examples
use bollard::Docker;
use futures::future::Future;
let connection = Docker::connect_with_http_defaults().unwrap();
connection.ping()
.and_then(|_| Ok(println!("Connected!")));
sourcepub fn connect_with_http(
addr: &str,
num_threads: usize,
timeout: u64
) -> Result<Docker<impl Connect>, Error>
pub fn connect_with_http(
addr: &str,
num_threads: usize,
timeout: u64
) -> Result<Docker<impl Connect>, Error>
Connect using unsecured HTTP.
Arguments
addr
: connection url including scheme and port.num_threads
: the number of threads for the HTTP connection pool.timeout
: the read/write timeout (seconds) to use for every hyper connection
Examples
use bollard::Docker;
use futures::future::Future;
let connection = Docker::connect_with_http(
"http://my-custom-docker-server:2735", 4, 20)
.unwrap();
connection.ping()
.and_then(|_| Ok(println!("Connected!")));
source§impl Docker<UnixConnector>
impl Docker<UnixConnector>
A Docker implementation typed to connect to a Unix socket.
sourcepub fn connect_with_unix_defaults() -> Result<Docker<impl Connect>, Error>
pub fn connect_with_unix_defaults() -> Result<Docker<impl Connect>, Error>
Connect using a Unix socket using defaults that are signalled by environment variables.
Defaults
- The socket location defaults to
/var/run/docker.sock
. - The request timeout defaults to 2 minutes.
Examples
use bollard::Docker;
use futures::future::Future;
let connection = Docker::connect_with_unix_defaults().unwrap();
connection.ping().and_then(|_| Ok(println!("Connected!")));
sourcepub fn connect_with_unix(
addr: &str,
timeout: u64
) -> Result<Docker<impl Connect>, Error>
pub fn connect_with_unix(
addr: &str,
timeout: u64
) -> Result<Docker<impl Connect>, Error>
Connect using a Unix socket.
Arguments
addr
: connection socket path.timeout
: the read/write timeout (seconds) to use for every hyper connection
Examples
use bollard::Docker;
use futures::future::Future;
let connection = Docker::connect_with_unix("/var/run/docker.sock", 120).unwrap();
connection.ping().and_then(|_| Ok(println!("Connected!")));
source§impl Docker<HttpsConnector<HttpConnector>>
impl Docker<HttpsConnector<HttpConnector>>
A Docker implementation typed to connect to a secure HTTPS connection, using the native rust TLS library.
sourcepub fn connect_with_tls_defaults(
) -> Result<Docker<HttpsConnector<HttpConnector>>, Error>
pub fn connect_with_tls_defaults(
) -> Result<Docker<HttpsConnector<HttpConnector>>, Error>
Connect using secure HTTPS using native TLS and defaults that are signalled by environment variables.
Defaults
- The connection url is sourced from the
DOCKER_HOST
environment variable. - The certificate directory is sourced from the
DOCKER_CERT_PATH
environment variable. - Certificate PKCS #12 archive is named
identity.pfx
and the certificate chain is namedca.pem
. - The password for the PKCS #12 archive defaults to an empty password.
- The number of threads used for the HTTP connection pool defaults to 1.
- The request timeout defaults to 2 minutes.
PKCS12
PKCS #12 archives can be created with OpenSSL:
openssl pkcs12 -export -out identity.pfx -inkey key.pem -in cert.pem -certfile
chain_certs.pem
Examples
use bollard::Docker;
use futures::future::Future;
let connection = Docker::connect_with_tls_defaults().unwrap();
connection.ping()
.and_then(|_| Ok(println!("Connected!")));
sourcepub fn connect_with_tls(
addr: &str,
pkcs12_file: &Path,
ca_file: &Path,
pkcs12_password: &str,
num_thread: usize,
timeout: u64
) -> Result<Docker<HttpsConnector<HttpConnector>>, Error>
pub fn connect_with_tls(
addr: &str,
pkcs12_file: &Path,
ca_file: &Path,
pkcs12_password: &str,
num_thread: usize,
timeout: u64
) -> Result<Docker<HttpsConnector<HttpConnector>>, Error>
Connect using secure HTTPS using native TLS.
Arguments
addr
: the connection url.pkcs12_file
: the PKCS #12 archive.ca_file
: the certificate chain.pkcs12_password
: the password to the PKCS #12 archive.num_threads
: the number of threads for the HTTP connection pool.timeout
: the read/write timeout (seconds) to use for every hyper connection
PKCS12
PKCS #12 archives can be created with OpenSSL:
openssl pkcs12 -export -out identity.pfx -inkey key.pem -in cert.pem -certfile
chain_certs.pem
Examples
use bollard::Docker;
use std::path::Path;
use futures::future::Future;
let connection = Docker::connect_with_tls(
"localhost:2375",
Path::new("/certs/identity.pfx"),
Path::new("/certs/ca.pem"),
"my_secret_password",
1,
120
).unwrap();
connection.ping()
.and_then(|_| Ok(println!("Connected!")));
source§impl<C> Docker<C>where
C: Connect + Sync + 'static,
impl<C> Docker<C>where
C: Connect + Sync + 'static,
sourcepub fn connect_with(
connector: C,
client_addr: String,
timeout: u64
) -> Result<Docker<C>, Error>
pub fn connect_with(
connector: C,
client_addr: String,
timeout: u64
) -> Result<Docker<C>, Error>
Connect using a type that implements hyper::Connect
.
Arguments
connector
: type that implementshyper::Connect
.client_addr
: location to connect to.timeout
: the read/write timeout (seconds) to use for every hyper connection
Examples
use bollard::Docker;
use futures::future::Future;
let mut connector = SequentialConnector::default();
connector.content.push(
"HTTP/1.1 200 OK\r\nServer: mock1\r\nContent-Type: application/json\r\nContent-Length: 0\r\n\r\n".to_string()
);
let connection = Docker::connect_with(connector, String::new(), 5).unwrap();
connection.ping()
.and_then(|_| Ok(println!("Connected!")));
source§impl<C> Docker<C>where
C: Connect + Sync + 'static,
impl<C> Docker<C>where
C: Connect + Sync + 'static,
sourcepub fn chain(self) -> DockerChain<C>
pub fn chain(self) -> DockerChain<C>
Create a chain of docker commands, useful to calling the API in a sequential manner.
Examples
use bollard::Docker;
let docker = Docker::connect_with_http_defaults().unwrap();
docker.chain();
source§impl<C> Docker<C>where
C: Connect + Sync + 'static,
impl<C> Docker<C>where
C: Connect + Sync + 'static,
sourcepub fn list_images<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = Vec<APIImages>, Error = Error>where
T: ListImagesQueryParams<K>,
K: AsRef<str>,
pub fn list_images<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = Vec<APIImages>, Error = Error>where
T: ListImagesQueryParams<K>,
K: AsRef<str>,
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
Arguments
- An optional List Images Options struct.
Returns
- Vector of API Images, 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.list_images(options);
sourcepub fn create_image<T, K, V>(
&self,
options: Option<T>
) -> impl Stream<Item = CreateImageResults, Error = Error>where
T: CreateImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn create_image<T, K, V>(
&self,
options: Option<T>
) -> impl Stream<Item = CreateImageResults, Error = Error>where
T: CreateImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Create Image
Create an image by either pulling it from a registry or importing it.
Arguments
- An optional Create Image Options struct.
Returns
- Create Image Results, wrapped in an asynchronous Stream.
Examples
use bollard::image::CreateImageOptions;
use std::default::Default;
let options = Some(CreateImageOptions{
from_image: "hello-world",
..Default::default()
});
docker.create_image(options);
// do some other work while the image is pulled from the docker hub...
Unsupported
- Import from tarball
sourcepub fn inspect_image(
&self,
image_name: &str
) -> impl Future<Item = Image, Error = Error>
pub fn inspect_image(
&self,
image_name: &str
) -> impl Future<Item = Image, Error = Error>
Inspect Image
Return low-level information about an image.
Arguments
- Image name as a string slice.
Returns
- Image, wrapped in a Future.
Examples
use std::default::Default;
docker.inspect_image("hello-world");
sourcepub fn prune_images<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = PruneImagesResults, Error = Error>where
T: PruneImagesQueryParams<K>,
K: AsRef<str>,
pub fn prune_images<T, K>(
&self,
options: Option<T>
) -> impl Future<Item = PruneImagesResults, Error = Error>where
T: PruneImagesQueryParams<K>,
K: AsRef<str>,
Prune Images
Delete unused images.
Arguments
- An optional Prune Images Options struct.
Returns
- a Prune Images Results, wrapped in a Future.
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.prune_images(options);
sourcepub fn image_history(
&self,
image_name: &str
) -> impl Future<Item = Vec<ImageHistory>, Error = Error>
pub fn image_history(
&self,
image_name: &str
) -> impl Future<Item = Vec<ImageHistory>, Error = Error>
Image History
Return parent layers of an image.
Arguments
- Image name as a string slice.
Returns
- Vector of Image History Results, wrapped in a Future.
Examples
docker.image_history("hello-world");
sourcepub fn search_images<T, K>(
&self,
options: T
) -> impl Future<Item = Vec<APIImageSearch>, Error = Error>where
T: SearchImagesQueryParams<K>,
K: AsRef<str>,
pub fn search_images<T, K>(
&self,
options: T
) -> impl Future<Item = Vec<APIImageSearch>, Error = Error>where
T: SearchImagesQueryParams<K>,
K: AsRef<str>,
Search Images
Search for an image on Docker Hub.
Arguments
- Search Image Options struct.
Returns
- Vector of API Image Search results, wrapped in a Future.
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.search_images(search_options);
sourcepub fn remove_image<T, K, V>(
&self,
image_name: &str,
options: Option<T>
) -> impl Future<Item = Vec<RemoveImageResults>, Error = Error>where
T: RemoveImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn remove_image<T, K, V>(
&self,
image_name: &str,
options: Option<T>
) -> impl Future<Item = Vec<RemoveImageResults>, Error = Error>where
T: RemoveImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Remove Image
Remove an image, along with any untagged parent images that were referenced by that image.
Arguments
- Image name as a string slice.
- An optional Remove Image Options struct.
Returns
- Vector of Remove Image Results, wrapped in a Future.
Examples
use bollard::image::RemoveImageOptions;
use std::default::Default;
let remove_options = Some(RemoveImageOptions {
force: true,
..Default::default()
});
docker.remove_image("hello-world", remove_options);
sourcepub fn tag_image<T, K, V>(
&self,
image_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: TagImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn tag_image<T, K, V>(
&self,
image_name: &str,
options: Option<T>
) -> impl Future<Item = (), Error = Error>where
T: TagImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Tag Image
Tag an image so that it becomes part of a repository.
Arguments
- Image name as a string slice.
- Optional Tag Image Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::image::TagImageOptions;
use std::default::Default;
let tag_options = Some(TagImageOptions {
tag: "v1.0.1",
..Default::default()
});
docker.tag_image("hello-world", tag_options);
sourcepub fn push_image<T, K, V>(
&self,
image_name: &str,
options: Option<T>,
credentials: Option<DockerCredentials>
) -> impl Future<Item = (), Error = Error>where
T: PushImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
pub fn push_image<T, K, V>(
&self,
image_name: &str,
options: Option<T>,
credentials: Option<DockerCredentials>
) -> impl Future<Item = (), Error = Error>where
T: PushImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Push Image
Push an image to a registry.
Arguments
- Image name as a string slice.
- Optional Push Image Options struct.
- Optional Docker Credentials struct.
Returns
- 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);
sourcepub fn commit_container<T, K, V, Z>(
&self,
options: T,
config: Config<Z>
) -> impl Future<Item = CommitContainerResults, Error = Error>where
T: CommitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: AsRef<str> + Eq + Hash + Serialize,
pub fn commit_container<T, K, V, Z>(
&self,
options: T,
config: Config<Z>
) -> impl Future<Item = CommitContainerResults, Error = Error>where
T: CommitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: AsRef<str> + Eq + Hash + Serialize,
Commit Container
Create a new image from a container.
Arguments
- Commit Container Options struct.
- Container Config struct.
Returns
- Commit Container Results, wrapped in a Future.
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.commit_container(options, config);