From f51b2c41a2001780fe67270691951b6533767e55 Mon Sep 17 00:00:00 2001 From: Andreas Hartmann Date: Mon, 21 Aug 2023 15:13:25 +0200 Subject: [PATCH] docker: Handle arbitrary extra arguments implemented in the configuration file and parsed from environment variables. --- src/docker/local.rs | 1 + src/docker/remote.rs | 3 +++ src/docker/shared.rs | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/src/docker/local.rs b/src/docker/local.rs index 4f3653459..ace2de3d1 100644 --- a/src/docker/local.rs +++ b/src/docker/local.rs @@ -41,6 +41,7 @@ pub(crate) fn run( let mut docker = engine.subcommand("run"); docker.add_userns(); + docker.add_extra_args(&options)?; // Podman on macOS doesn't support selinux labels, see issue #756 #[cfg(target_os = "macos")] diff --git a/src/docker/remote.rs b/src/docker/remote.rs index 9a6d3185b..64f7e8b00 100644 --- a/src/docker/remote.rs +++ b/src/docker/remote.rs @@ -758,6 +758,9 @@ pub(crate) fn run( msg_info, ) .wrap_err("could not determine mount points")?; + docker + .add_extra_args(&options) + .wrap_err("could not determine additional container arguments")?; docker .add_seccomp(engine.kind, target, &paths.metadata) diff --git a/src/docker/shared.rs b/src/docker/shared.rs index 83ec3bfc9..b8625c577 100644 --- a/src/docker/shared.rs +++ b/src/docker/shared.rs @@ -955,6 +955,7 @@ pub(crate) trait DockerCommandExt { target: &Target, metadata: &CargoMetadata, ) -> Result<()>; + fn add_extra_args(&mut self, options: &DockerOptions) -> Result<()>; fn add_mounts( &mut self, options: &DockerOptions, @@ -1164,6 +1165,16 @@ impl DockerCommandExt for Command { Ok(()) } + fn add_extra_args(&mut self, options: &DockerOptions) -> Result<()> { + let extra_args = options.config.extra_args(&options.target)?; + if let Some(args) = extra_args { + args.iter().for_each(|arg| { + self.arg(arg); + }); + } + Ok(()) + } + fn add_mounts( &mut self, options: &DockerOptions,