Skip to main content

Docker

Struct Docker 

Source
pub struct Docker { /* private fields */ }
Expand description

The local Docker Engine.

Implementations§

Source§

impl Docker

Source

pub fn connect() -> Result<Docker, Error>

Connects to the Docker Engine at DOCKER_HOST, or its local socket. Only unix:// hosts are supported.

Source

pub async fn info(&self) -> Result<SystemInfo, Error>

The Engine’s system information.

Source

pub async fn image_labels( &self, image: &str, ) -> Result<Option<HashMap<String, String>>, Error>

An image’s labels; None when Docker does not have it.

Source

pub async fn registry_platforms( &self, image: &str, ) -> Result<Vec<String>, Error>

Asks the image’s registry for its manifest, without pulling it, and returns the platforms it is built for, such as linux/amd64. An error means pull could not get it.

Trait Implementations§

Source§

impl Debug for Docker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DockerApi for Docker

Source§

async fn start( &self, spec: &RunnerSpec, isolation: &dyn Isolation, ) -> Result<String, StartError>

Creates and starts a runner container; returns its ID. A start that fails removes what it made, and says which container is left when it cannot.
Source§

async fn inspect(&self, container: &str) -> Result<RunnerState, Error>

A container’s state and isolation.
Source§

async fn remove(&self, container: &str) -> Result<(), Error>

Removes a runner container, stopping it first if it runs.
Source§

async fn run( &self, name: &str, body: ContainerCreateBody, ) -> Result<String, Error>

Creates and starts a container that is not a runner, such as the mirror; returns its ID.
Source§

async fn list(&self, label: &str) -> Result<Vec<Container>, Error>

Every container, running or not, that has the label.
Source§

fn exits(&self) -> BoxStream<'static, Result<String, Error>>

The IDs of runner containers (labelled runnerd.job) as each stops, from Docker’s events. A hint: Docker sends an event once at most, none while the stream is down, and keeps none to replay. The stream fails or ends with the connection, or when Docker restarts.
Source§

async fn wait(&self, container: &str) -> Result<i64, Error>

Waits for a container to exit; returns its exit code.
Source§

async fn logs(&self, container: &str) -> Result<String, Error>

A container’s output so far, stdout and stderr interleaved.
Source§

async fn logs_since(&self, container: &str, since: u64) -> Result<String, Error>

A container’s output since since (seconds since the epoch), each line prefixed with Docker’s RFC 3339 timestamp and a space.
Source§

async fn exec( &self, container: &str, command: Vec<String>, ) -> Result<Output, Error>

Runs a command as root in a running container; its stdout streams until it exits or the container stops. Its stderr is dropped.
Source§

async fn image_present(&self, image: &str) -> Result<bool, Error>

Whether Docker has an image.
Source§

async fn pull(&self, image: &str) -> Result<(), Error>

Pulls an image, logging its progress every few seconds.
Source§

async fn ensure_network(&self, name: &str) -> Result<(), Error>

Creates a bridge network unless it exists.
Source§

async fn ensure_volume(&self, name: &str) -> Result<(), Error>

Creates a volume unless it exists.
Source§

async fn remove_volume(&self, name: &str) -> Result<(), Error>

Removes a volume; a volume that does not exist is not an error.
Source§

async fn volume_sizes(&self) -> Result<BTreeMap<String, u64>, Error>

The disk size of every volume Docker knows, by name. Slow: Docker measures each volume.
Source§

async fn changes(&self, container: &str) -> Result<Vec<String>, Error>

The paths a container’s own layer added or changed, not those it deleted.
Source§

async fn written(&self, container: &str) -> Result<u64, Error>

The bytes a container’s own layer holds.
Source§

async fn files( &self, container: &str, directory: &str, prefix: &str, ) -> Result<Files, Error>

The files directly in a container’s directory whose names start with prefix, not those in the directories below it, read from its filesystem whether it runs or stopped, without starting it.
Source§

async fn commit( &self, container: &str, reference: &str, labels: BTreeMap<String, String>, ) -> Result<u64, Error>

Commits a stopped container’s own layer as the image reference (repository:tag) with labels; returns the disk the image takes beyond its parent.
Source§

async fn images(&self, label: &str) -> Result<Vec<Image>, Error>

Every image with the label.
Source§

async fn image_id(&self, reference: &str) -> Result<Option<String>, Error>

The ID of the image a reference (tag, digest or ID) names; None when Docker does not have it.
Source§

async fn tagged_images(&self) -> Result<Vec<TaggedImage>, Error>

Every image Docker has a tag for.
Source§

async fn container_images(&self) -> Result<BTreeSet<String>, Error>

The image ID of every container, running or stopped.
Source§

async fn remove_image(&self, reference: &str) -> Result<(), Error>

Removes an image and the layers only it used; one that does not exist is not an error.
Source§

async fn free_space(&self) -> Result<u64, Error>

The free disk where Docker keeps its images and containers.
Source§

async fn shell( &self, name: &str, body: ContainerCreateBody, size: TtySize, ) -> Result<Tty, Error>

Creates a container with a terminal of size, attaches to it and starts it. The container’s stdin closes when Tty::input is dropped.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more