pub struct Docker { /* private fields */ }Expand description
Handle to connection to the docker daemon
Implementations§
Source§impl Docker
impl Docker
pub fn set_credential(&self, credential: Credential)
Sourcepub fn connect_with_defaults() -> Result<Docker, DwError>
pub fn connect_with_defaults() -> Result<Docker, DwError>
Connect to the Docker daemon
§Summary
Connect to the Docker daemon using the standard Docker configuration options. This includes:
DOCKER_HOSTDOCKER_TLS_VERIFYDOCKER_CERT_PATHDOCKER_CONFIG
and we try to interpret these as much like the standard docker client as possible.
Sourcepub fn connect_with_unix(addr: &str) -> Result<Docker, DwError>
pub fn connect_with_unix(addr: &str) -> Result<Docker, DwError>
This ensures that using a fully-qualified path
e.g. unix://…. – works. The unix socket provider expects a Path, so we don’t need scheme.
pub fn connect_with_ssl( _addr: &str, _key: &Path, _cert: &Path, _ca: &Path, ) -> Result<Docker, DwError>
Sourcepub fn connect_with_http(addr: &str) -> Result<Docker, DwError>
pub fn connect_with_http(addr: &str) -> Result<Docker, DwError>
Connect using unsecured HTTP. This is strongly discouraged everywhere but on Windows when npipe support is not available.
Sourcepub async fn list_containers(
&self,
all: Option<bool>,
limit: Option<u64>,
size: Option<bool>,
filters: ContainerFilters,
) -> Result<Vec<Container>, DwError>
pub async fn list_containers( &self, all: Option<bool>, limit: Option<u64>, size: Option<bool>, filters: ContainerFilters, ) -> Result<Vec<Container>, DwError>
Sourcepub async fn create_container(
&self,
name: Option<&str>,
option: &ContainerCreateOptions,
) -> Result<CreateContainerResponse, DwError>
pub async fn create_container( &self, name: Option<&str>, option: &ContainerCreateOptions, ) -> Result<CreateContainerResponse, DwError>
Sourcepub async fn attach_container(
&self,
id: &str,
detachKeys: Option<&str>,
logs: bool,
stream: bool,
stdin: bool,
stdout: bool,
stderr: bool,
) -> Result<BoxStream<'static, Result<AttachResponseFrame, DwError>>, DwError>
pub async fn attach_container( &self, id: &str, detachKeys: Option<&str>, logs: bool, stream: bool, stdin: bool, stdout: bool, stderr: bool, ) -> Result<BoxStream<'static, Result<AttachResponseFrame, DwError>>, DwError>
Attach to a container
Attach to a container to read its output or send it input.
§API
/containers/{id}/attach
Sourcepub async fn exec_container(
&self,
id: &str,
option: &CreateExecOptions,
) -> Result<CreateExecResponse, DwError>
pub async fn exec_container( &self, id: &str, option: &CreateExecOptions, ) -> Result<CreateExecResponse, DwError>
Create Exec instance for a container
Run a command inside a running container.
§API
/containers/{id}/exec
Sourcepub async fn start_exec(
&self,
id: &str,
option: &StartExecOptions,
) -> Result<BoxStream<'static, Result<AttachResponseFrame, DwError>>, DwError>
pub async fn start_exec( &self, id: &str, option: &StartExecOptions, ) -> Result<BoxStream<'static, Result<AttachResponseFrame, DwError>>, DwError>
Start an exec instance
Starts a previously set up exec instance. If detach is true, this endpoint returns immediately after starting the command. Otherwise, it sets up an interactive session with the command.
§API
/exec/{id}/start
Sourcepub async fn log_container(
&self,
id: &str,
option: &ContainerLogOptions,
) -> Result<BoxStream<'static, Result<String, DwError>>, DwError>
pub async fn log_container( &self, id: &str, option: &ContainerLogOptions, ) -> Result<BoxStream<'static, Result<String, DwError>>, DwError>
pub async fn processes( &self, container_id: &str, ) -> Result<Vec<Process>, DwError>
Sourcepub async fn stats(
&self,
container_id: &str,
stream: Option<bool>,
oneshot: Option<bool>,
) -> Result<BoxStream<'static, Result<Stats, DwError>>, DwError>
pub async fn stats( &self, container_id: &str, stream: Option<bool>, oneshot: Option<bool>, ) -> Result<BoxStream<'static, Result<Stats, DwError>>, DwError>
Sourcepub async fn wait_container(&self, id: &str) -> Result<ExitStatus, DwError>
pub async fn wait_container(&self, id: &str) -> Result<ExitStatus, DwError>
Sourcepub async fn remove_container(
&self,
id: &str,
volume: Option<bool>,
force: Option<bool>,
link: Option<bool>,
) -> Result<(), DwError>
pub async fn remove_container( &self, id: &str, volume: Option<bool>, force: Option<bool>, link: Option<bool>, ) -> Result<(), DwError>
Sourcepub async fn prune_containers(
&self,
filters: ContainerPruneFilters,
) -> Result<PrunedContainers, DwError>
pub async fn prune_containers( &self, filters: ContainerPruneFilters, ) -> Result<PrunedContainers, DwError>
Sourcepub async fn get_file(
&self,
id: &str,
path: &Path,
) -> Result<BoxStream<'static, Result<Bytes, DwError>>, DwError>
pub async fn get_file( &self, id: &str, path: &Path, ) -> Result<BoxStream<'static, Result<Bytes, DwError>>, DwError>
Sourcepub async fn head_file(
&self,
id: &str,
path: &Path,
) -> Result<XDockerContainerPathStat, DwError>
pub async fn head_file( &self, id: &str, path: &Path, ) -> Result<XDockerContainerPathStat, DwError>
Sourcepub async fn put_file(
&self,
id: &str,
src: &Path,
dst: &Path,
noOverwriteDirNonDir: bool,
) -> Result<(), DwError>
pub async fn put_file( &self, id: &str, src: &Path, dst: &Path, noOverwriteDirNonDir: bool, ) -> Result<(), DwError>
Extract an archive of files or folders to a directory in a container
§Summary
Extract given src file into the container specified with id. The input file must be a tar archive with id(no compress), gzip, bzip2 or xz.
- id : container name or ID
- src : path to a source file
- dst : path to a directory in the container to extract the archive’s contents into
§API
/containers/{id}/archive
Sourcepub async fn build_image(
&self,
options: ContainerBuildOptions,
tar_path: &Path,
) -> Result<BoxStream<'static, Result<DockerResponse, DwError>>, DwError>
pub async fn build_image( &self, options: ContainerBuildOptions, tar_path: &Path, ) -> Result<BoxStream<'static, Result<DockerResponse, DwError>>, DwError>
Sourcepub async fn create_image(
&self,
image: &str,
tag: &str,
) -> Result<BoxStream<'static, Result<DockerResponse, DwError>>, DwError>
pub async fn create_image( &self, image: &str, tag: &str, ) -> Result<BoxStream<'static, Result<DockerResponse, DwError>>, DwError>
Create an image by pulling it from registry
§API
/images/create?fromImage={image}&tag={tag}
§NOTE
When control returns from this function, creating job may not have been completed.
For waiting the completion of the job, consuming response like
create_image("hello-world", "linux").map(|r| r.for_each(|_| ()));.
§TODO
- Typing result iterator like image::ImageStatus.
- Generalize input parameters
Sourcepub async fn remove_image(
&self,
name: &str,
force: Option<bool>,
noprune: Option<bool>,
) -> Result<Vec<RemovedImage>, DwError>
pub async fn remove_image( &self, name: &str, force: Option<bool>, noprune: Option<bool>, ) -> Result<Vec<RemovedImage>, DwError>
Sourcepub async fn prune_image(&self, dangling: bool) -> Result<PrunedImages, DwError>
pub async fn prune_image(&self, dangling: bool) -> Result<PrunedImages, DwError>
Sourcepub async fn history_image(
&self,
name: &str,
) -> Result<Vec<ImageLayer>, DwError>
pub async fn history_image( &self, name: &str, ) -> Result<Vec<ImageLayer>, DwError>
Sourcepub async fn search_images(
&self,
term: &str,
limit: Option<u64>,
filters: ImageFilters,
) -> Result<Vec<FoundImage>, DwError>
pub async fn search_images( &self, term: &str, limit: Option<u64>, filters: ImageFilters, ) -> Result<Vec<FoundImage>, DwError>
Sourcepub async fn export_image(
&self,
name: &str,
) -> Result<BoxStream<'static, Result<Bytes, DwError>>, DwError>
pub async fn export_image( &self, name: &str, ) -> Result<BoxStream<'static, Result<Bytes, DwError>>, DwError>
Sourcepub async fn auth(
&self,
username: &str,
password: &str,
email: &str,
serveraddress: &str,
) -> Result<AuthToken, DwError>
pub async fn auth( &self, username: &str, password: &str, email: &str, serveraddress: &str, ) -> Result<AuthToken, DwError>
Sourcepub async fn system_info(&self) -> Result<SystemInfo, DwError>
pub async fn system_info(&self) -> Result<SystemInfo, DwError>
Sourcepub async fn container_info(
&self,
container_id: &str,
) -> Result<ContainerInfo, DwError>
pub async fn container_info( &self, container_id: &str, ) -> Result<ContainerInfo, DwError>
Sourcepub async fn filesystem_changes(
&self,
container_id: &str,
) -> Result<Vec<FilesystemChange>, DwError>
pub async fn filesystem_changes( &self, container_id: &str, ) -> Result<Vec<FilesystemChange>, DwError>
Get changes on a container’s filesystem.
(This is the same as docker container diff command.)
§API
/containers/{id}/changes