diff options
author | Szymon Janota <szymon.janota@sap.com> | 2018-12-22 11:30:47 +0100 |
---|---|---|
committer | doug tangren <d.tangren@gmail.com> | 2018-12-22 19:30:47 +0900 |
commit | bf79d766cd9eaf57b2674629659fd298ad04e39f (patch) | |
tree | 7e2f669c0f6c3b489e4ae4162f8a22c9d267ed3a /src | |
parent | e27b98daccf405027a0e1d5f72fe1ec6fd8ec8c7 (diff) |
Support for AutoRemove flag (#137)
* Support for AutoRemove flag
* Rust fmt
Diffstat (limited to 'src')
-rw-r--r-- | src/builder.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/builder.rs b/src/builder.rs index 7f6f26d..cc3fc83 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -603,6 +603,14 @@ impl ContainerOptionsBuilder { self } + pub fn auto_remove( + &mut self, + set: bool, + ) -> &mut Self { + self.params.insert("HostConfig.AutoRemove", json!(set)); + self + } + pub fn build(&self) -> ContainerOptions { ContainerOptions { name: self.name.clone(), @@ -1338,10 +1346,11 @@ mod tests { fn container_options_host_config() { let options = ContainerOptionsBuilder::new("test_image") .network_mode("host") + .auto_remove(true) .build(); assert_eq!( - r#"{"HostConfig":{"NetworkMode":"host"},"Image":"test_image"}"#, + r#"{"HostConfig":{"AutoRemove":true,"NetworkMode":"host"},"Image":"test_image"}"#, options.serialize().unwrap() ); } |