diff options
Diffstat (limited to 'src/builder.rs')
-rw-r--r-- | src/builder.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/builder.rs b/src/builder.rs index 0eecfa1..5541605 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -911,6 +911,14 @@ impl ContainerOptionsBuilder { self } + pub fn user( + &mut self, + user: &str, + ) -> &mut Self { + self.params.insert("User", json!(user)); + self + } + pub fn build(&self) -> ContainerOptions { ContainerOptions { name: self.name.clone(), @@ -1658,6 +1666,18 @@ mod tests { } #[test] + fn container_options_user() { + let options = ContainerOptionsBuilder::new("test_image") + .user("alice") + .build(); + + assert_eq!( + r#"{"HostConfig":{},"Image":"test_image","User":"alice"}"#, + options.serialize().unwrap() + ); + } + + #[test] fn container_options_host_config() { let options = ContainerOptionsBuilder::new("test_image") .network_mode("host") |