[−][src]Struct harbourmaster::Container
Abstraction of a running Docker container.
Use the new method to create a Container with sensible defaults, or the builder method if you need advanced features.
Container constructors return a future which will be resolved to a Container. The Containers will NOT clean themselves up when they are dropped, you must call the delete method on them to remove the container from the host machine.
Methods
impl Container
[src]
pub async fn new(image_name: impl Into<String>) -> Result<Container, Error>
[src]
Create a new Docker container.
Example
use harbourmaster::Container; use tokio; let future03 = async { let image = "alpine"; let container = Container::new(image).await.unwrap(); println!("container created!"); container.delete().await.unwrap(); println!("container deleted!"); Ok(()) }; // For the time being, we have to convert the future from a future-0.3 to a future-0.1 to run on the tokio executor use futures::future::{FutureExt, TryFutureExt}; let future01 = future03.boxed().compat(); tokio::run(future01);
pub fn builder(image_name: impl Into<String>) -> ContainerBuilder
[src]
Create a new Docker container with advanced configuration.
Check the ContainerBuilder documentation for the full list of options.
Example
use harbourmaster::{Container, Protocol}; use tokio; let future03 = async { let container = Container::builder("couchdb") // the docker image tag to use .tag("2.3.0") // set the name of the docker container .name("test_container") // optionally add an alphanumeric 'slug' to the // container name. Useful if you're creating and // naming them in bulk .slug_length(6) // expose ports on the container to the host machine .expose(5984, 5984, Protocol::Tcp) // if true, pull the image from the webular information // super-highway before building. .pull_on_build(true) // build the container using the above parameters .build() .await .unwrap(); println!("container created!"); container.delete().await.unwrap(); println!("container deleted!"); Ok(()) }; // For the time being, we have to convert the future from a future-0.3 to a future-0.1 to run on the tokio executor use futures::future::{FutureExt, TryFutureExt}; let future01 = future03.boxed().compat(); tokio::run(future01);
pub fn id(&self) -> &str
[src]
Return the Docker id of the running container
pub fn ports(&self) -> &HashMap<(u16, Protocol), Vec<SocketAddrV4>>
[src]
Not yet implemented
pub fn ports_raw(
&self
) -> &Option<HashMap<String, Option<Vec<HashMap<String, String>>>>>
[src]
&self
) -> &Option<HashMap<String, Option<Vec<HashMap<String, String>>>>>
Exposes the underlying representation of the Docker container's ports. It's messy, this part of the API will change shortly.
pub async fn delete(self) -> Result<(), Error>
[src]
Delete the running docker container.
This is equivalent to calling docker rm -f [container]
.
Auto Trait Implementations
impl Sync for Container
impl Send for Container
impl Unpin for Container
impl !RefUnwindSafe for Container
impl !UnwindSafe for Container
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,