summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/builder.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/builder.rs b/src/builder.rs
index 35fccb9..631c1af 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -642,6 +642,14 @@ impl ContainerOptionsBuilder {
self
}
+ /// enable all exposed ports on the container to be mapped to random, available, ports on the host
+ pub fn publish_all_ports(
+ &mut self,
+ ) -> &mut Self {
+ self.params.insert("HostConfig.PublishAllPorts", json!(true));
+ self
+ }
+
pub fn expose(
&mut self,
srcport: u32,
@@ -1707,6 +1715,19 @@ mod tests {
);
}
+ /// Test container option PublishAllPorts
+ #[test]
+ fn container_options_publish_all_ports() {
+ let options = ContainerOptionsBuilder::new("test_image")
+ .publish_all_ports()
+ .build();
+
+ assert_eq!(
+ r#"{"HostConfig":{"PublishAllPorts":true},"Image":"test_image"}"#,
+ options.serialize().unwrap()
+ );
+ }
+
/// Test container options that are nested 3 levels deep.
#[test]
fn container_options_nested() {