[−][src]Struct bollard::Docker
Docker
The main interface for calling the Docker API. Construct a new Docker instance using one of the connect methods:
Implementations
impl Docker
[src]
pub async fn list_containers<'de, '_, T, K>(
&'_ self,
options: Option<T>
) -> Result<Vec<ContainerSummaryInner>, Error> where
T: ListContainersQueryParams<K, String>,
K: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<Vec<ContainerSummaryInner>, Error> where
T: ListContainersQueryParams<K, String>,
K: AsRef<str>,
List Containers
Returns a list of containers.
Arguments
- Optional ListContainersOptions struct.
Returns
- Vector of ContainerSummaryInner, 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);
pub async fn create_container<'_, T, K, V, Z>(
&'_ self,
options: Option<T>,
config: Config<Z>
) -> Result<ContainerCreateResponse, Error> where
T: CreateContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: Into<String> + Hash + Eq + Serialize,
[src]
&'_ self,
options: Option<T>,
config: Config<Z>
) -> Result<ContainerCreateResponse, Error> where
T: CreateContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: Into<String> + Hash + Eq + Serialize,
Create Container
Prepares a container for a subsequent start operation.
Arguments
- Optional Create Container Options struct.
- Container Config struct.
Returns
- ContainerCreateResponse, 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);
pub async fn start_container<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), Error> where
T: StartContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), 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>>);
pub async fn stop_container<'_, '_, T, K>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), Error> where
T: StopContainerQueryParams<K>,
K: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), 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);
pub async fn remove_container<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), Error> where
T: RemoveContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), 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);
pub fn wait_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<ContainerWaitResponse, Error>> where
T: WaitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<ContainerWaitResponse, 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
- ContainerWaitResponse, wrapped in a Stream.
Examples
use bollard::container::WaitContainerOptions; let options = Some(WaitContainerOptions{ condition: "not-running", }); docker.wait_container("hello-world", options);
pub async fn restart_container<'_, '_, T, K>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), Error> where
T: RestartContainerQueryParams<K>,
K: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), 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);
pub async fn inspect_container<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<ContainerInspectResponse, Error> where
T: InspectContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<ContainerInspectResponse, 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
- ContainerInspectResponse, wrapped in a Future.
Examples
use bollard::container::InspectContainerOptions; let options = Some(InspectContainerOptions{ size: false, }); docker.inspect_container("hello-world", options);
pub async fn top_processes<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<ContainerTopResponse, Error> where
T: TopQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<ContainerTopResponse, 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
- ContainerTopResponse, wrapped in a Future.
Examples
use bollard::container::TopOptions; let options = Some(TopOptions{ ps_args: "aux", }); docker.top_processes("fussybeaver/uhttpd", options);
pub fn logs<T, K>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<LogOutput, Error>> where
T: LogsQueryParams<K>,
K: AsRef<str>,
[src]
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<LogOutput, 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);
pub async fn container_changes<'_, '_>(
&'_ self,
container_name: &'_ str
) -> Result<Option<Vec<ContainerChangeResponseItem>>, Error>
[src]
&'_ self,
container_name: &'_ str
) -> Result<Option<Vec<ContainerChangeResponseItem>>, Error>
Container Changes
Get changes on a container's filesystem.
Arguments
- Container name as string slice.
Returns
- An Option of Vector of Container Change Response Item structs, wrapped in a Future.
Examples
docker.container_changes("hello-world");
pub fn stats<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<Stats, Error>> where
T: StatsQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<Stats, 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);
pub async fn kill_container<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), Error> where
T: KillContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>
) -> Result<(), 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);
pub async fn update_container<'_, '_, T: Into<String> + Eq + Hash + Serialize>(
&'_ self,
container_name: &'_ str,
config: UpdateContainerOptions<T>
) -> Result<(), Error>
[src]
&'_ self,
container_name: &'_ str,
config: UpdateContainerOptions<T>
) -> Result<(), 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::<String> { memory: Some(314572800), memory_swap: Some(314572800), ..Default::default() }; docker.update_container("postgres", config);
pub async fn rename_container<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: T
) -> Result<(), Error> where
T: RenameContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: T
) -> Result<(), 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);
pub async fn pause_container<'_, '_>(
&'_ self,
container_name: &'_ str
) -> Result<(), Error>
[src]
&'_ self,
container_name: &'_ str
) -> Result<(), 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");
pub async fn unpause_container<'_, '_>(
&'_ self,
container_name: &'_ str
) -> Result<(), Error>
[src]
&'_ self,
container_name: &'_ str
) -> Result<(), 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");
pub async fn prune_containers<'_, T, K>(
&'_ self,
options: Option<T>
) -> Result<ContainerPruneResponse, Error> where
T: PruneContainersQueryParams<K>,
K: AsRef<str> + Eq + Hash,
[src]
&'_ self,
options: Option<T>
) -> Result<ContainerPruneResponse, Error> where
T: PruneContainersQueryParams<K>,
K: AsRef<str> + Eq + Hash,
Prune Containers
Delete stopped containers.
Arguments
- Optional Prune Containers Options struct.
Returns
- Container Prune Response 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);
pub async fn upload_to_container<'_, '_, T, K, V>(
&'_ self,
container_name: &'_ str,
options: Option<T>,
tar: Body
) -> Result<(), Error> where
T: UploadToContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
container_name: &'_ str,
options: Option<T>,
tar: Body
) -> Result<(), Error> where
T: UploadToContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Upload To Container
Upload a tar archive to be extracted to a path in the filesystem of container id.
Arguments
- Optional Upload To Container Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::container::UploadToContainerOptions; use std::default::Default; use std::fs::File; use std::io::Read; let options = Some(UploadToContainerOptions{ path: "/opt", ..Default::default() }); let mut file = File::open("tarball.tar.gz").unwrap(); let mut contents = Vec::new(); file.read_to_end(&mut contents).unwrap(); docker.upload_to_container("my-container", options, contents.into());
pub fn download_from_container<T, K, V>(
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<Bytes, Error>> where
T: DownloadFromContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&self,
container_name: &str,
options: Option<T>
) -> impl Stream<Item = Result<Bytes, Error>> where
T: DownloadFromContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Download From Container
Get a tar archive of a resource in the filesystem of container id.
Arguments
- Download From Container Options struct.
Returns
- Tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. Hyper Body.
Examples
use bollard::container::DownloadFromContainerOptions; let options = Some(DownloadFromContainerOptions{ path: "/opt", }); docker.download_from_container("my-container", options);
impl Docker
[src]
A Docker implementation typed to connect to an unsecure Http connection.
pub fn connect_with_http_defaults() -> Result<Docker, Error>
[src]
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_util::future::TryFutureExt; let connection = Docker::connect_with_http_defaults().unwrap(); connection.ping() .map_ok(|_| Ok::<_, ()>(println!("Connected!")));
pub fn connect_with_http(
addr: &str,
timeout: u64,
client_version: &ClientVersion
) -> Result<Docker, Error>
[src]
addr: &str,
timeout: u64,
client_version: &ClientVersion
) -> Result<Docker, Error>
Connect using unsecured HTTP.
Arguments
addr
: connection url including scheme and port.timeout
: the read/write timeout (seconds) to use for every hyper connectionclient_version
: the client version to communicate with the server.
Examples
use bollard::{API_DEFAULT_VERSION, Docker}; use futures_util::future::TryFutureExt; let connection = Docker::connect_with_http( "http://my-custom-docker-server:2735", 4, API_DEFAULT_VERSION) .unwrap(); connection.ping() .map_ok(|_| Ok::<_, ()>(println!("Connected!")));
impl Docker
[src]
A Docker implementation typed to connect to a Unix socket.
pub fn connect_with_unix_defaults() -> Result<Docker, Error>
[src]
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_util::future::TryFutureExt; let connection = Docker::connect_with_unix_defaults().unwrap(); connection.ping().map_ok(|_| Ok::<_, ()>(println!("Connected!")));
pub fn connect_with_unix(
addr: &str,
timeout: u64,
client_version: &ClientVersion
) -> Result<Docker, Error>
[src]
addr: &str,
timeout: u64,
client_version: &ClientVersion
) -> Result<Docker, Error>
Connect using a Unix socket.
Arguments
addr
: connection socket path.timeout
: the read/write timeout (seconds) to use for every hyper connectionclient_version
: the client version to communicate with the server.
Examples
use bollard::{API_DEFAULT_VERSION, Docker}; use futures_util::future::TryFutureExt; let connection = Docker::connect_with_unix("/var/run/docker.sock", 120, API_DEFAULT_VERSION).unwrap(); connection.ping().map_ok(|_| Ok::<_, ()>(println!("Connected!")));
impl Docker
[src]
A Docker implementation that wraps away which local implementation we are calling.
pub fn connect_with_local_defaults() -> Result<Docker, Error>
[src]
Connect using the local machine connection method with default arguments.
This is a simple wrapper over the OS specific handlers:
pub fn connect_with_local(
addr: &str,
timeout: u64,
client_version: &ClientVersion
) -> Result<Docker, Error>
[src]
addr: &str,
timeout: u64,
client_version: &ClientVersion
) -> Result<Docker, Error>
Connect using the local machine connection method with supplied arguments.
This is a simple wrapper over the OS specific handlers:
- Unix:
Docker::connect_with_unix
- Windows:
Docker::connect_with_named_pipe
impl Docker
[src]
pub fn client_version(&self) -> ClientVersion
[src]
Return the currently set client version.
pub async fn negotiate_version(self) -> Result<Self, Error>
[src]
Check with the server for a supported version, and downgrade the client version if appropriate.
Examples:
use bollard::Docker; let docker = Docker::connect_with_http_defaults().unwrap(); async move { &docker.negotiate_version().await.unwrap().version(); };
impl Docker
[src]
pub async fn create_exec<'_, '_, T>(
&'_ self,
container_name: &'_ str,
config: CreateExecOptions<T>
) -> Result<CreateExecResults, Error> where
T: AsRef<str> + Serialize,
[src]
&'_ self,
container_name: &'_ str,
config: CreateExecOptions<T>
) -> Result<CreateExecResults, Error> where
T: AsRef<str> + Serialize,
Create Exec
Run a command inside a running container.
Arguments
- Container name as string slice.
- Create Exec Options struct.
Returns
- A Create Exec Results struct, wrapped in a Future.
Examples
use bollard::exec::CreateExecOptions; use std::default::Default; let config = CreateExecOptions { cmd: Some(vec!["ps", "-ef"]), attach_stdout: Some(true), ..Default::default() }; docker.create_exec("hello-world", config);
pub fn start_exec(
&self,
container_name: &str,
config: Option<StartExecOptions>
) -> impl Stream<Item = Result<StartExecResults, Error>>
[src]
&self,
container_name: &str,
config: Option<StartExecOptions>
) -> impl Stream<Item = Result<StartExecResults, Error>>
Start Exec
Starts a previously set up exec instance. If detach is true, this endpoint returns immediately after starting the command.
Arguments
- Container name as string slice.
Returns
- Log Output enum, wrapped in a Stream.
Examples
use bollard::exec::StartExecOptions; docker.start_exec("hello-world", None::<StartExecOptions>);
pub async fn inspect_exec<'_, '_>(
&'_ self,
container_name: &'_ str
) -> Result<ExecInspect, Error>
[src]
&'_ self,
container_name: &'_ str
) -> Result<ExecInspect, Error>
Inspect Exec
Return low-level information about an exec instance.
Arguments
- Container name as string slice.
Returns
- An ExecInspect struct, wrapped in a Future.
Examples
docker.inspect_exec("hello-world");
impl Docker
[src]
pub async fn list_images<'_, T, K>(
&'_ self,
options: Option<T>
) -> Result<Vec<ImageSummary>, Error> where
T: ListImagesQueryParams<K>,
K: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<Vec<ImageSummary>, 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", vec!["true"]); let options = Some(ListImagesOptions{ all: true, filters: filters, ..Default::default() }); docker.list_images(options);
pub fn create_image<T, K, V>(
&self,
options: Option<T>,
root_fs: Option<Body>,
credentials: Option<DockerCredentials>
) -> impl Stream<Item = Result<CreateImageResults, Error>> where
T: CreateImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&self,
options: Option<T>,
root_fs: Option<Body>,
credentials: Option<DockerCredentials>
) -> impl Stream<Item = Result<CreateImageResults, 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.
- An optional request body consisting of a tar or tar.gz archive with the root file system
for the image. If this argument is used, the value of the
from_src
option must be "-".
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, None, None); // do some other work while the image is pulled from the docker hub...
Unsupported
- Import from tarball
pub async fn inspect_image<'_, '_>(
&'_ self,
image_name: &'_ str
) -> Result<Image, Error>
[src]
&'_ self,
image_name: &'_ str
) -> Result<Image, 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");
pub async fn prune_images<'_, T, K>(
&'_ self,
options: Option<T>
) -> Result<PruneImagesResults, Error> where
T: PruneImagesQueryParams<K>,
K: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<PruneImagesResults, 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", vec!["10m"]); let options = Some(PruneImagesOptions { filters: filters }); docker.prune_images(options);
pub async fn image_history<'_, '_>(
&'_ self,
image_name: &'_ str
) -> Result<Vec<ImageHistory>, Error>
[src]
&'_ self,
image_name: &'_ str
) -> Result<Vec<ImageHistory>, 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");
pub async fn search_images<'_, T, K>(
&'_ self,
options: T
) -> Result<Vec<APIImageSearch>, Error> where
T: SearchImagesQueryParams<K>,
K: AsRef<str>,
[src]
&'_ self,
options: T
) -> Result<Vec<APIImageSearch>, 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);
pub async fn remove_image<'_, '_, T, K, V>(
&'_ self,
image_name: &'_ str,
options: Option<T>,
credentials: Option<DockerCredentials>
) -> Result<Vec<RemoveImageResults>, Error> where
T: RemoveImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
image_name: &'_ str,
options: Option<T>,
credentials: Option<DockerCredentials>
) -> Result<Vec<RemoveImageResults>, 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, None);
pub async fn tag_image<'_, '_, T, K, V>(
&'_ self,
image_name: &'_ str,
options: Option<T>
) -> Result<(), Error> where
T: TagImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
image_name: &'_ str,
options: Option<T>
) -> Result<(), 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);
pub async fn push_image<'_, '_, T, K, V>(
&'_ self,
image_name: &'_ str,
options: Option<T>,
credentials: Option<DockerCredentials>
) -> Result<(), Error> where
T: PushImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
image_name: &'_ str,
options: Option<T>,
credentials: Option<DockerCredentials>
) -> Result<(), 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; use std::default::Default; let push_options = Some(PushImageOptions { tag: "v1.0.1", }); let credentials = Some(DockerCredentials { username: Some("Jack".to_string()), password: Some("myverysecretpassword".to_string()), ..Default::default() }); docker.push_image("hello-world", push_options, credentials);
pub async fn commit_container<'_, T, K, V, Z>(
&'_ self,
options: T,
config: Config<Z>
) -> Result<CommitContainerResults, Error> where
T: CommitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: Into<String> + Eq + Hash + Serialize,
[src]
&'_ self,
options: T,
config: Config<Z>
) -> Result<CommitContainerResults, Error> where
T: CommitContainerQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Z: Into<String> + 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);
pub fn build_image<T, K>(
&self,
options: T,
credentials: Option<HashMap<String, DockerCredentials>>,
tar: Option<Body>
) -> impl Stream<Item = Result<BuildImageResults, Error>> where
T: BuildImageQueryParams<K>,
K: AsRef<str>,
[src]
&self,
options: T,
credentials: Option<HashMap<String, DockerCredentials>>,
tar: Option<Body>
) -> impl Stream<Item = Result<BuildImageResults, Error>> where
T: BuildImageQueryParams<K>,
K: AsRef<str>,
Build Image
Build an image from a tar archive with a Dockerfile
in it.
The Dockerfile
specifies how the image is built from the tar archive. It is typically in
the archive's root, but can be at a different path or have a different name by specifying
the dockerfile
parameter.
Arguments
- Build Image Options struct.
- Optional Docker Credentials struct.
- Tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. Optional Hyper Body.
Returns
- Build Image Results, wrapped in an asynchronous Stream.
Examples
use bollard::image::BuildImageOptions; use bollard::container::Config; use std::default::Default; use std::fs::File; use std::io::Read; let options = BuildImageOptions{ dockerfile: "Dockerfile", t: "my-image", rm: true, ..Default::default() }; let mut file = File::open("tarball.tar.gz").unwrap(); let mut contents = Vec::new(); file.read_to_end(&mut contents).unwrap(); docker.build_image(options, None, Some(contents.into()));
pub fn export_image(
&self,
image_name: &str
) -> impl Stream<Item = Result<Bytes, Error>>
[src]
&self,
image_name: &str
) -> impl Stream<Item = Result<Bytes, Error>>
Export Image
Get a tarball containing all images and metadata for a repository.
The root of the resulting tar file will contain the file "mainifest.json". If the export is
of an image repository, rather than a signle image, there will also be a repositories
file
with a JSON description of the exported image repositories.
Additionally, each layer of all exported images will have a sub directory in the archive
containing the filesystem of the layer.
See the Docker API documentation for more information.
Arguments
- The
image_name
string can refer to an individual image and tag (e.g. alpine:latest), an individual image by I
Returns
- An uncompressed TAR archive
pub fn import_image<K, V, T>(
&self,
options: T,
root_fs: Body,
credentials: Option<HashMap<String, DockerCredentials>>
) -> impl Stream<Item = Result<ImportImageResults, Error>> where
T: ImportImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&self,
options: T,
root_fs: Body,
credentials: Option<HashMap<String, DockerCredentials>>
) -> impl Stream<Item = Result<ImportImageResults, Error>> where
T: ImportImageQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Import Image
Load a set of images and tags into a repository.
For details on the format, see the export image endpoint.
Arguments
- Image Import Options struct.
Returns
- Import Image Results, wrapped in an asynchronous Stream.
Examples
use bollard::image::ImportImageOptions; use bollard::errors::Error; use std::default::Default; use tokio::fs::File; use tokio::io::AsyncWriteExt; use tokio_util::codec; use tokio::stream::StreamExt; let options = ImportImageOptions{ ..Default::default() }; async move { let mut file = File::open("tarball.tar.gz").await.unwrap(); let byte_stream = codec::FramedRead::new(file, codec::BytesCodec::new()).map(|r| { let bytes = r.unwrap().freeze(); Ok::<_, Error>(bytes) }); let body = hyper::Body::wrap_stream(byte_stream); let mut stream = docker .import_image( ImportImageOptions { ..Default::default() }, body, None, ); while let Some(response) = stream.next().await { // ... } };
impl Docker
[src]
pub async fn create_network<'_, T>(
&'_ self,
config: CreateNetworkOptions<T>
) -> Result<CreateNetworkResults, Error> where
T: AsRef<str> + Eq + Hash + Serialize,
[src]
&'_ self,
config: CreateNetworkOptions<T>
) -> Result<CreateNetworkResults, Error> where
T: AsRef<str> + Eq + Hash + Serialize,
Create Network
Create a new network.
Arguments
- Create Network Options struct.
Returns
- A Create Network Results struct, wrapped in a Future.
Examples
use bollard::network::CreateNetworkOptions; use std::default::Default; let config = CreateNetworkOptions { name: "certs", ..Default::default() }; docker.create_network(config);
pub async fn remove_network<'_, '_>(
&'_ self,
network_name: &'_ str
) -> Result<(), Error>
[src]
&'_ self,
network_name: &'_ str
) -> Result<(), Error>
Remove a Network
Arguments
- Network name as a string slice.
Returns
- unit type
()
, wrapped in a Future.
Examples
docker.remove_network("my_network_name");
pub async fn inspect_network<'a, '_, '_, T, V>(
&'_ self,
network_name: &'_ str,
options: Option<T>
) -> Result<InspectNetworkResults, Error> where
T: InspectNetworkQueryParams<'a, V>,
V: AsRef<str>,
[src]
&'_ self,
network_name: &'_ str,
options: Option<T>
) -> Result<InspectNetworkResults, Error> where
T: InspectNetworkQueryParams<'a, V>,
V: AsRef<str>,
Inspect a Network
Arguments
- Network name as a string slice.
Returns
- A Inspect Network Results struct, wrapped in a Future.
Examples
use bollard::network::InspectNetworkOptions; use std::default::Default; let config = InspectNetworkOptions { verbose: true, scope: "global" }; docker.inspect_network("my_network_name", Some(config));
pub async fn list_networks<'_, T, K, V>(
&'_ self,
options: Option<T>
) -> Result<Vec<ListNetworksResults>, Error> where
T: ListNetworksQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<Vec<ListNetworksResults>, Error> where
T: ListNetworksQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
List Networks
Arguments
- Optional List Network Options struct.
Returns
- A vector of List Networks Results struct, wrapped in a Future.
Examples
use bollard::network::ListNetworksOptions; use std::collections::HashMap; let mut list_networks_filters = HashMap::new(); list_networks_filters.insert("label", vec!["maintainer=some_maintainer"]); let config = ListNetworksOptions { filters: list_networks_filters, }; docker.list_networks(Some(config));
pub async fn connect_network<'_, '_, T>(
&'_ self,
network_name: &'_ str,
config: ConnectNetworkOptions<T>
) -> Result<(), Error> where
T: AsRef<str> + Eq + Hash + Serialize,
[src]
&'_ self,
network_name: &'_ str,
config: ConnectNetworkOptions<T>
) -> Result<(), Error> where
T: AsRef<str> + Eq + Hash + Serialize,
Connect Network
Arguments
- A Connect Network Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::network::{EndpointSettings, EndpointIPAMConfig, ConnectNetworkOptions}; use std::default::Default; let config = ConnectNetworkOptions { container: "3613f73ba0e4", endpoint_config: EndpointSettings { ipam_config: EndpointIPAMConfig { ipv4_address: Some("172.24.56.89"), ipv6_address: Some("2001:db8::5689"), ..Default::default() }, ..Default::default() } }; docker.connect_network("my_network_name", config);
pub async fn disconnect_network<'_, '_, T>(
&'_ self,
network_name: &'_ str,
config: DisconnectNetworkOptions<T>
) -> Result<(), Error> where
T: AsRef<str> + Serialize,
[src]
&'_ self,
network_name: &'_ str,
config: DisconnectNetworkOptions<T>
) -> Result<(), Error> where
T: AsRef<str> + Serialize,
Disconnect Network
Arguments
- A Disconnect Network Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::network::DisconnectNetworkOptions; use std::default::Default; let config = DisconnectNetworkOptions { container: "3613f73ba0e4", force: true }; docker.disconnect_network("my_network_name", config);
pub async fn prune_networks<'_, T, K, V>(
&'_ self,
options: Option<T>
) -> Result<PruneNetworksResults, Error> where
T: PruneNetworksQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<PruneNetworksResults, Error> where
T: PruneNetworksQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Prune Networks
Deletes networks which are unused.
Arguments
- A Prune Networks Options struct.
Returns
- A Prune Networks Results struct.
Examples
use bollard::network::PruneNetworksOptions; use std::collections::HashMap; let mut filters = HashMap::new(); filters.insert("label", vec!("maintainer=some_maintainer")); let options = PruneNetworksOptions { filters: filters, }; docker.prune_networks(Some(options));
impl Docker
[src]
pub async fn list_services<'_, T, K>(
&'_ self,
options: Option<T>
) -> Result<Vec<Service>, Error> where
T: ListServicesQueryParams<K, String>,
K: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<Vec<Service>, Error> where
T: ListServicesQueryParams<K, String>,
K: AsRef<str>,
List Services
Returns a list of services.
Arguments
- Optional ListServicesOptions struct.
Returns
- Vector of Services, wrapped in a Future.
Examples
use bollard::service::ListServicesOptions; use std::collections::HashMap; use std::default::Default; let mut filters = HashMap::new(); filters.insert("mode", vec!("global")); let options = Some(ListServicesOptions{ filters: filters, ..Default::default() }); docker.list_services(options);
pub async fn create_service<'_>(
&'_ self,
service_spec: ServiceSpec,
credentials: Option<DockerCredentials>
) -> Result<ServiceCreateResponse, Error>
[src]
&'_ self,
service_spec: ServiceSpec,
credentials: Option<DockerCredentials>
) -> Result<ServiceCreateResponse, Error>
Create Service
Dispatch a new service on the docker swarm
Arguments
- ServiceSpec struct.
- Optional Docker Credentials struct.
Returns
- A Service Create Response struct, wrapped in a Future.
Examples
use bollard::service::{ ServiceSpec, ServiceSpecMode, ServiceSpecModeReplicated, TaskSpec, TaskSpecContainerSpec }; let service = ServiceSpec { name: Some(String::from("my-service")), mode: Some(ServiceSpecMode { replicated: Some(ServiceSpecModeReplicated { replicas: Some(2) }), ..Default::default() }), task_template: Some(TaskSpec { container_spec: Some(TaskSpecContainerSpec { image: Some(String::from("hello-world")), ..Default::default() }), ..Default::default() }), ..Default::default() }; let credentials = None; docker.create_service(service, credentials);
pub async fn inspect_service<'_, '_, T, K, V>(
&'_ self,
service_name: &'_ str,
options: Option<T>
) -> Result<Service, Error> where
T: InspectServiceQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
service_name: &'_ str,
options: Option<T>
) -> Result<Service, Error> where
T: InspectServiceQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Inspect Service
Inspect a service.
Arguments
- Service name or id as a string slice.
- Optional Inspect Service Options struct.
Returns
- Service, wrapped in a Future.
Examples
use bollard::service::InspectServiceOptions; let options = Some(InspectServiceOptions{ insert_defaults: true, }); docker.inspect_service("my-service", options);
pub async fn delete_service<'_, '_>(
&'_ self,
service_name: &'_ str
) -> Result<(), Error>
[src]
&'_ self,
service_name: &'_ str
) -> Result<(), Error>
Delete Service
Delete a service.
Arguments
- Service name or id as a string slice.
Returns
- unit type
()
, wrapped in a Future.
Examples
docker.delete_service("my-service");
pub async fn update_service<'_, '_, T, K>(
&'_ self,
service_name: &'_ str,
service_spec: ServiceSpec,
options: T,
credentials: Option<DockerCredentials>
) -> Result<ServiceUpdateResponse, Error> where
T: UpdateServiceQueryParams<K, String>,
K: AsRef<str>,
[src]
&'_ self,
service_name: &'_ str,
service_spec: ServiceSpec,
options: T,
credentials: Option<DockerCredentials>
) -> Result<ServiceUpdateResponse, Error> where
T: UpdateServiceQueryParams<K, String>,
K: AsRef<str>,
Update Service
Update an existing service
Arguments
- Service name or id as a string slice.
- ServiceSpec struct.
- UpdateServiceOptions struct.
- Optional Docker Credentials struct.
Returns
- A Service Update Response struct, wrapped in a Future.
Examples
use bollard::service::{ InspectServiceOptions, ServiceSpec, ServiceSpecMode, ServiceSpecModeReplicated, TaskSpec, TaskSpecContainerSpec, UpdateServiceOptions, }; use std::collections::HashMap; use std::default::Default; let result = async move { let service_name = "my-service"; let current_version = docker.inspect_service( service_name, None::<InspectServiceOptions> ).await?.version.unwrap().index.unwrap(); let service = ServiceSpec { mode: Some(ServiceSpecMode { replicated: Some(ServiceSpecModeReplicated { replicas: Some(0) }), ..Default::default() }), ..Default::default() }; let options = UpdateServiceOptions { version: current_version, ..Default::default() }; let credentials = None; docker.update_service("my-service", service, options, credentials).await };
impl Docker
[src]
pub async fn version<'_>(&'_ self) -> Result<Version, Error>
[src]
Version
Returns the version of Docker that is running and various information about the system that Docker is running on.
Returns
- Version, wrapped in a Future.
Examples
docker.version();
pub async fn ping<'_>(&'_ self) -> Result<String, Error>
[src]
Ping
This is a dummy endpoint you can use to test if the server is accessible.
Returns
- A String, wrapped in a Future.
Examples
docker.ping();
pub fn events<T, K, V>(
&self,
options: Option<T>
) -> impl Stream<Item = Result<SystemEventsResponse, Error>> where
T: EventsQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&self,
options: Option<T>
) -> impl Stream<Item = Result<SystemEventsResponse, Error>> where
T: EventsQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Events
Stream real-time events from the server.
Returns
- System Events Response, wrapped in a Stream.
Examples
use bollard::system::EventsOptions; use chrono::{Duration, Utc}; use std::collections::HashMap; docker.events(Some(EventsOptions::<String> { since: Utc::now() - Duration::minutes(20), until: Utc::now(), filters: HashMap::new(), }));
pub async fn df<'_>(&'_ self) -> Result<SystemDataUsageResponse, Error>
[src]
Get data usage information
Show docker disk usage
Returns
- System Data Usage Response, wrapped in a Future.
Examples
docker.df();
impl Docker
[src]
pub async fn list_volumes<'_, T>(
&'_ self,
options: Option<ListVolumesOptions<T>>
) -> Result<ListVolumesResults, Error> where
T: AsRef<str> + Eq + Hash + Serialize,
[src]
&'_ self,
options: Option<ListVolumesOptions<T>>
) -> Result<ListVolumesResults, Error> where
T: AsRef<str> + Eq + Hash + Serialize,
List volumes
Arguments
- List Volumes Options struct.
Returns
- A List Volumes Results struct, wrapped in a Future.
Examples
use bollard::volume::ListVolumesOptions; use std::collections::HashMap; let mut filters = HashMap::new(); filters.insert("dangling", vec!("1")); let options = ListVolumesOptions { filters: filters, }; docker.list_volumes(Some(options));
pub async fn create_volume<'_, T>(
&'_ self,
config: CreateVolumeOptions<T>
) -> Result<VolumeAPI, Error> where
T: AsRef<str> + Eq + Hash + Serialize,
[src]
&'_ self,
config: CreateVolumeOptions<T>
) -> Result<VolumeAPI, Error> where
T: AsRef<str> + Eq + Hash + Serialize,
Create Volume
Create a new volume.
Arguments
- Create Volume Options struct.
Returns
- A Volume Api struct, wrapped in a Future.
Examples
use bollard::volume::CreateVolumeOptions; use std::default::Default; let config = CreateVolumeOptions { name: "certs", ..Default::default() }; docker.create_volume(config);
pub async fn inspect_volume<'_, '_>(
&'_ self,
volume_name: &'_ str
) -> Result<VolumeAPI, Error>
[src]
&'_ self,
volume_name: &'_ str
) -> Result<VolumeAPI, Error>
Inspect a Volume
Arguments
- Volume name as a string slice.
Returns
- A Volume API struct, wrapped in a Future.
Examples
docker.inspect_volume("my_volume_name");
pub async fn remove_volume<'_, '_>(
&'_ self,
volume_name: &'_ str,
options: Option<RemoveVolumeOptions>
) -> Result<(), Error>
[src]
&'_ self,
volume_name: &'_ str,
options: Option<RemoveVolumeOptions>
) -> Result<(), Error>
Remove a Volume
Arguments
- Volume name as a string slice.
Arguments
- Remove Volume Options struct.
Returns
- unit type
()
, wrapped in a Future.
Examples
use bollard::volume::RemoveVolumeOptions; let options = RemoveVolumeOptions { force: true, }; docker.remove_volume("my_volume_name", Some(options));
pub async fn prune_volumes<'_, T, K, V>(
&'_ self,
options: Option<T>
) -> Result<PruneVolumesResults, Error> where
T: PruneVolumesQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
[src]
&'_ self,
options: Option<T>
) -> Result<PruneVolumesResults, Error> where
T: PruneVolumesQueryParams<K, V>,
K: AsRef<str>,
V: AsRef<str>,
Prune Volumes
Delete unused volumes.
Arguments
- A Prune Volumes Options struct.
Returns
- A Prune Volumes Results struct.
Examples
use bollard::volume::PruneVolumesOptions; use std::collections::HashMap; let mut filters = HashMap::new(); filters.insert("label", vec!("maintainer=some_maintainer")); let options = PruneVolumesOptions { filters: filters, }; docker.prune_volumes(Some(options));
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Docker
impl Send for Docker
impl Sync for Docker
impl Unpin for Docker
impl !UnwindSafe for Docker
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,