GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support selecting the container engine (docker or Apple Container) by fnando · Pull Request #2643 · stellar/stellar-cli

Support selecting the container engine (docker or Apple Container) #2643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
fnando merged 3 commits into main from container-engine-selection
Jul 16, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Support selecting the container engine (docker or Apple Container) #2643

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
6450568
Add --engine flag to pick docker or Apple Container.
fnando Jul 13, 2026
bc619cd
Cover Apple container error messages in tests.
fnando Jul 13, 2026
4158028
Warn in doctor when container engine is invalid.
fnando Jul 16, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

16 changes: 16 additions & 0 deletions 16 FULL_HELP_DOCS.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,11 @@ Get logs from a running network container
###### **Options:**

- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
- `--engine <ENGINE>` — Container engine to use [default: docker]

Possible values:
- `docker`: Docker, or any Docker-compatible CLI
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)

## `stellar container start`

Expand All @@ -1698,6 +1703,12 @@ By default, when starting a testnet container, without any optional arguments, i
###### **Options:**

- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
- `--engine <ENGINE>` — Container engine to use [default: docker]

Possible values:
- `docker`: Docker, or any Docker-compatible CLI
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)

- `--name <NAME>` — Optional argument to specify the container name
- `-l`, `--limits <LIMITS>` — Optional argument to specify the limits for the local network only
- `-p`, `--ports-mapping <PORTS_MAPPING>` — Argument to specify the `HOST_PORT:CONTAINER_PORT` mapping
Expand All @@ -1722,6 +1733,11 @@ Stop a network container started with `stellar container start`
###### **Options:**

- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
- `--engine <ENGINE>` — Container engine to use [default: docker]

Possible values:
- `docker`: Docker, or any Docker-compatible CLI
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)

## `stellar config`

Expand Down
281 changes: 281 additions & 0 deletions 281 cmd/crates/soroban-test/tests/it/container.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
//! End-to-end tests for `stellar container start|stop|logs`.
//!
//! These never touch a real container runtime. Instead they drop a fake `docker`
//! / `container` executable into a temp dir, point `PATH` at it, and assert on
//! both the CLI's behavior and the exact argv the fake was invoked with. This
//! exercises the real spawn path and stderr classification that the unit tests in
//! `shared.rs` can't reach.
Comment thread
fnando marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;

use assert_cmd::Command;
use predicates::prelude::predicate;
use soroban_test::TestEnv;

/// A sandbox with an isolated `PATH` that only contains the fake engines we
/// explicitly install, so the real `docker`/`container` on the host is never hit.
struct EngineSandbox {
env: TestEnv,
bin_dir: PathBuf,
log: PathBuf,
}

impl EngineSandbox {
fn new() -> Self {
let env = TestEnv::default();
let bin_dir = env.dir().join("fake-bin");
fs::create_dir_all(&bin_dir).unwrap();
let log = env.dir().join("engine-invocations.log");
Self { env, bin_dir, log }
}

/// Installs a fake engine binary named `name` (e.g. `docker` or `container`).
/// Each invocation appends its argv to the shared log; behavior is driven by
/// the `FAKE_ENGINE_MODE` env var (`ok`, `already_running`, `not_found`). The
/// stderr wording matches the real engine the binary is impersonating so the
/// CLI's per-engine classifiers are exercised end-to-end.
fn install_engine(&self, name: &str) {
// Real-world stderr strings the CLI classifies, per engine.
let (already_running, not_found) = if name == "container" {
(
"Error: container with id stellar-local already exists",
r#"Error: internalError: "failed to stop container" (cause: "notFound: "container with ID stellar-local not found"")"#,
)
} else {
(
r#"docker: Error response from daemon: Conflict. The container name "/stellar-local" is already in use."#,
"Error response from daemon: No such container: stellar-local",
)
};
let script = format!(
r#"#!/bin/sh
echo "{name} $@" >> "{log}"
case " $* " in
*" pull "*) exit 0 ;;
*" run "*)
case "$FAKE_ENGINE_MODE" in
already_running)
echo '{already_running}' >&2
exit 1 ;;
*) exit 0 ;;
esac ;;
*" stop "*)
case "$FAKE_ENGINE_MODE" in
not_found)
echo '{not_found}' >&2
exit 1 ;;
*) exit 0 ;;
esac ;;
*) exit 0 ;;
esac
"#,
name = name,
log = self.log.display(),
);
let path = self.bin_dir.join(name);
fs::write(&path, script).unwrap();
fs::set_permissions(&path, fs::Permissions::from_mode(0o755)).unwrap();
}

/// Builds a `container` subcommand whose `PATH` is only the fake bin dir.
fn cmd(&self, mode: &str) -> Command {
let mut cmd = self.env.new_assert_cmd("container");
cmd.env("PATH", &self.bin_dir)
.env("FAKE_ENGINE_MODE", mode)
// Don't inherit a real DOCKER_HOST/engine from the developer's shell.
.env_remove("DOCKER_HOST")
.env_remove("STELLAR_CONTAINER_ENGINE");
cmd
}

fn invocations(&self) -> String {
fs::read_to_string(&self.log).unwrap_or_default()
}
}

fn line_for(log: &str, needle: &str) -> String {
log.lines()
.find(|l| l.contains(needle))
.unwrap_or_else(|| panic!("no invocation containing {needle:?} in:\n{log}"))
.to_string()
}

#[test]
fn start_defaults_to_docker_and_passes_expected_args() {
let s = EngineSandbox::new();
s.install_engine("docker");

s.cmd("ok")
.args(["start", "local"])
.assert()
.success()
.stderr(predicate::str::contains("Started container"));

let log = s.invocations();
// Pulled and ran via docker (not the apple `image pull` form).
assert!(line_for(&log, "pull").starts_with("docker pull "));
let run = line_for(&log, " run ");
assert!(run.starts_with("docker "), "expected docker binary: {run}");
assert!(run.contains("--name stellar-local"), "run line: {run}");
assert!(run.contains("-p 8000:8000"), "run line: {run}");
// No host override unless requested.
assert!(!run.contains("-H "), "unexpected -H: {run}");
}

#[test]
fn start_passes_docker_host_as_h_flag() {
let s = EngineSandbox::new();
s.install_engine("docker");

s.cmd("ok")
.args(["start", "local", "--docker-host", "ssh://me@host"])
.assert()
.success();

let run = line_for(&s.invocations(), " run ");
assert!(run.contains("-H ssh://me@host"), "run line: {run}");
}

#[test]
fn start_reports_already_running_from_stderr() {
let s = EngineSandbox::new();
s.install_engine("docker");

s.cmd("already_running")
.args(["start", "local"])
.assert()
.failure()
.stderr(predicate::str::contains("already running"));
}

#[test]
fn stop_success() {
let s = EngineSandbox::new();
s.install_engine("docker");

s.cmd("ok")
.args(["stop", "local"])
.assert()
.success()
.stderr(predicate::str::contains("Container stopped"));

assert!(line_for(&s.invocations(), " stop ").contains("stop stellar-local"));
}

#[test]
fn stop_reports_not_found_from_stderr() {
let s = EngineSandbox::new();
s.install_engine("docker");

s.cmd("not_found")
.args(["stop", "local"])
.assert()
.failure()
.stderr(predicate::str::contains("container local not found"));
}

#[test]
fn apple_engine_uses_container_binary_and_image_pull() {
let s = EngineSandbox::new();
// Only the apple engine exists on PATH; if the CLI shelled out to docker it
// would fail with a not-found error instead.
s.install_engine("container");

s.cmd("ok")
.args(["start", "local", "--engine", "apple-container"])
.assert()
.success();

let log = s.invocations();
// Apple groups image ops under `image` (singular) and takes no `--tail`.
assert!(line_for(&log, "pull").starts_with("container image pull "));
let run = line_for(&log, " run ");
assert!(
run.starts_with("container "),
"expected container binary: {run}"
);
}

#[test]
fn apple_engine_reports_already_running_from_stderr() {
let s = EngineSandbox::new();
s.install_engine("container");

// The fake `container` emits Apple's `already exists` wording, so this only
// passes if the CLI classifies stderr with the apple-container matcher.
s.cmd("already_running")
.args(["start", "local", "--engine", "apple-container"])
.assert()
.failure()
.stderr(predicate::str::contains("already running"));
}

#[test]
fn apple_engine_reports_not_found_from_stderr() {
let s = EngineSandbox::new();
s.install_engine("container");

// The fake `container` emits Apple's `not found` wording here.
s.cmd("not_found")
.args(["stop", "local", "--engine", "apple-container"])
.assert()
.failure()
.stderr(predicate::str::contains("container local not found"));
}

#[test]
fn apple_engine_selectable_via_env_var() {
let s = EngineSandbox::new();
s.install_engine("container");

s.cmd("ok")
.env("STELLAR_CONTAINER_ENGINE", "apple-container")
.args(["start", "local"])
.assert()
.success();

assert!(line_for(&s.invocations(), " run ").starts_with("container "));
}

#[test]
fn warns_and_drops_docker_host_for_apple_engine() {
let s = EngineSandbox::new();
s.install_engine("container");

s.cmd("ok")
.args([
"start",
"local",
"--engine",
"apple-container",
"--docker-host",
"ssh://me@host",
])
.assert()
.success()
.stderr(predicate::str::contains(
"is ignored because the `apple-container` engine",
));

// The ignored host must not reach the container binary.
assert!(
!s.invocations().contains("-H "),
"host leaked to container CLI"
);
}

#[test]
fn errors_when_engine_binary_is_missing() {
// No engine installed on the isolated PATH.
let s = EngineSandbox::new();

s.cmd("ok")
.args(["stop", "local"])
.assert()
.failure()
.stderr(predicate::str::contains(
"is docker installed and on your PATH?",
));
}
2 changes: 2 additions & 0 deletions 2 cmd/crates/soroban-test/tests/it/main.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod build;
mod config;
#[cfg(unix)]
mod container;
#[cfg(feature = "emulator-tests")]
mod emulator;
mod help;
Expand Down
11 changes: 7 additions & 4 deletions 11 cmd/soroban-cli/src/commands/container/logs.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::commands::{container::shared::Error as ConnectionError, global};
use crate::print;

use super::shared::{Args, Name};

Expand All @@ -22,17 +23,19 @@ pub struct Cmd {
}

impl Cmd {
pub async fn run(&self, _global_args: &global::Args) -> Result<(), Error> {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
let print = print::Print::new(global_args.quiet);
let container_name = Name(self.name.clone()).get_internal_container_name();

self.container_args.warn_if_host_ignored(&print);

// Stream logs straight to the terminal by inheriting stdio.
let status = self
.container_args
.docker_command()
.args(["logs", "-f", "--tail", "all", &container_name])
.logs_command(&container_name)
.status()
.await
.map_err(ConnectionError::from)?;
.map_err(|e| self.container_args.io_error(e))?;

if !status.success() {
return Err(Error::TailContainerError);
Expand Down
2 changes: 1 addition & 1 deletion 2 cmd/soroban-cli/src/commands/container/mod.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::commands::global;

pub(crate) mod logs;
mod shared;
pub(crate) mod shared;
pub(crate) mod start;
pub(crate) mod stop;

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.