microsoft/autogen · critical · ValueError

Failed to start container from image {self._image}. Logs: {l

Error message

Failed to start container from image {self._image}. Logs: {logs_str}

What it means

Raised by DockerCommandLineCodeExecutor.start() after the container is created and _wait_for_ready() returns, but container.status is still not 'running'. The container's own log output is appended so you can see why the entrypoint failed inside the container.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.py:565

            working_dir="/workspace",
            extra_hosts=self._extra_hosts,
            device_requests=self._device_requests,
        )
        await asyncio.to_thread(self._container.start)

        await _wait_for_ready(self._container)

        async def cleanup() -> None:
            await self.stop()
            asyncio_atexit.unregister(cleanup)  # type: ignore

        if self._stop_container:
            asyncio_atexit.register(cleanup)  # type: ignore

        # Check if the container is running
        if self._container.status != "running":
            logs_str = self._container.logs().decode("utf-8")
            raise ValueError(f"Failed to start container from image {self._image}. Logs: {logs_str}")

        self._loop = asyncio.get_running_loop()
        self._cancellation_futures = []
        logging.debug(f"Executor started, associated with event loop: {self._loop!r}")

        self._running = True

    def _to_config(self) -> DockerCommandLineCodeExecutorConfig:
        """(Experimental) Convert the component to a config object."""
        if self._functions:
            logging.info("Functions will not be included in serialized configuration")

        return DockerCommandLineCodeExecutorConfig(
            image=self._image,
            container_name=self.container_name,
            timeout=self._timeout,
            work_dir=str(self._work_dir) if self._work_dir else None,
            bind_dir=str(self._bind_dir) if self._bind_dir else None,

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Read the appended container Logs in the exception message - it states the actual container-start failure.
  2. Test the image manually: docker run --rm <image> and confirm it stays up; fix its entrypoint/CMD or use the default python:3-slim image.
  3. Rebuild the custom image (docker build --no-cache ...) in case it is stale or built for the wrong platform (--platform linux/amd64).
  4. If OOM-killed, free memory or raise Docker's memory limits.

Example fix

# before
executor = DockerCommandLineCodeExecutor(image="my-custom-executor")
await executor.start()  # ValueError: Failed to start container ... Logs: exec /bin/sh: exec format error

# after
# rebuild for the host platform and verify it stays running:
#   docker build --platform linux/amd64 -t my-custom-executor .
#   docker run --rm -d my-custom-executor sleep 30
executor = DockerCommandLineCodeExecutor(image="my-custom-executor")
await executor.start()
Defensive patterns

Strategy: try-catch

Validate before calling

import docker

def image_present(image: str) -> bool:
    try:
        docker.from_env().images.get(image)
        return True
    except Exception:
        return False

Try / catch

try:
    await executor.start()
except ValueError as e:
    if str(e).startswith("Failed to start container"):
        logs = str(e).split("Logs:", 1)[-1]  # container logs for diagnosis
        raise RuntimeError(f"Container image broken, check entrypoint: {logs}") from e
    raise

Prevention

When it happens

Trigger: Supplying a custom image whose entrypoint immediately exits (bad command, missing binary), an image that crashes on startup, a container that dies between the readiness wait and the status check, or resource constraints (OOM) killing the container at start.

Common situations: Using a minimal image without /bin/sh or the expected sleep entrypoint, images built for a different architecture (exec format error), images whose default CMD exits instantly, Docker daemon out of memory, or stale/broken custom images cached locally.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/2df22aa05c1d6f48. Report an issue: GitHub.