Skip to content

Commit 8cb7df5

Browse files
bors[bot]oblique
andauthored
Merge #472
472: Add a way to choose Podman instead of Docker r=reitermarkus a=oblique By default, `cross` tries to use Docker or Podman, with the former to have priority. In you want to use other container engine or explicitly choose one you can set the name of binary (or the path) in `CROSS_CONTAINER_ENGINE` environment variable. For example in case you want use Podman, you can set `CROSS_CONTAINER_ENGINE=podman`. Co-authored-by: oblique <[email protected]>
2 parents 6ff4818 + 3203136 commit 8cb7df5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ overlayfs can not be unmounted correctly by Docker if the child container still
166166
accesses it.
167167

168168

169+
### Explicitly choose the container engine
170+
171+
By default, `cross` tries to use [Docker] or [Podman], in that order.
172+
If you want to choose a container engine explicitly, you can set the
173+
binary name (or path) using the `CROSS_CONTAINER_ENGINE`
174+
environment variable.
175+
176+
For example in case you want use [Podman], you can set `CROSS_CONTAINER_ENGINE=podman`.
177+
169178
### Passing environment variables into the build environment
170179

171180
By default, `cross` does not pass any environment variables into the build

src/docker.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ const DOCKER: &str = "docker";
1717
const PODMAN: &str = "podman";
1818

1919
fn get_container_engine() -> Result<std::path::PathBuf> {
20-
which::which(DOCKER).or_else(|_| which::which(PODMAN)).map_err(|e| e.into())
20+
let container_engine = env::var("CROSS_CONTAINER_ENGINE").unwrap_or_default();
21+
22+
if container_engine.is_empty() {
23+
which::which(DOCKER)
24+
.or_else(|_| which::which(PODMAN))
25+
.map_err(|e| e.into())
26+
} else {
27+
which::which(container_engine).map_err(|e| e.into())
28+
}
2129
}
2230

2331
pub fn docker_command(subcommand: &str) -> Result<Command> {

0 commit comments

Comments
 (0)