{"record":{"id":"1a41d513d9e7a08d","repo":"microsoft/autogen","slug":"custom-image-image-name-does-not-exist","errorCode":null,"errorMessage":"Custom image {image_name} does not exist","messagePattern":"Custom image (.+?) does not exist","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/docker_jupyter/_jupyter_server.py","lineNumber":347,"sourceCode":"\n        # Determine and prepare Docker image\n        image_name = custom_image_name or \"autogen-jupyterkernelgateway\"\n        if not custom_image_name:\n            try:\n                client.images.get(image_name)\n            except docker.errors.ImageNotFound:\n                # Build default image if not found\n                here = Path(__file__).parent\n                dockerfile = io.BytesIO(self.DEFAULT_DOCKERFILE.encode(\"utf-8\"))\n                logging.info(f\"Building image {image_name}...\")\n                client.images.build(path=str(here), fileobj=dockerfile, tag=image_name)\n                logging.info(f\"Image {image_name} built successfully\")\n        else:\n            # Verify custom image exists\n            try:\n                client.images.get(image_name)\n            except docker.errors.ImageNotFound as err:\n                raise ValueError(f\"Custom image {image_name} does not exist\") from err\n        if docker_env is None:\n            docker_env = {}\n        if token is None:\n            token = DockerJupyterServer.GenerateToken()\n        # Set up authentication token\n        self._token = secrets.token_hex(32) if isinstance(token, DockerJupyterServer.GenerateToken) else token\n\n        # Prepare environment variables\n        env = {\"TOKEN\": self._token}\n        env.update(docker_env)\n\n        # Define volume configuration if bind directory is specified\n        volumes = {str(self._bind_dir): {\"bind\": str(work_dir), \"mode\": \"rw\"}} if self._bind_dir else None\n\n        # Start the container\n        container = client.containers.run(\n            image_name,\n            detach=True,","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/docker_jupyter/_jupyter_server.py#L329-L365","documentation":"Raised in DockerJupyterServer.__init__ when a custom image name is supplied but client.images.get() raises ImageNotFound. Unlike the default image path (which auto-builds), custom images must already exist locally; they are neither pulled nor built for you.","triggerScenarios":"Constructing DockerJupyterServer with a custom image name that was never built/pulled on this machine, an image that exists only in a remote registry (no pull is attempted), or a mistyped tag.","commonSituations":"CI or fresh machines where the custom image was never built, forgetting to docker build before running tests, typos in the tag, images removed by docker system prune.","solutions":["Build or pull the image first: docker build -t my-jupyter . or docker pull registry/my-jupyter, then construct DockerJupyterServer.","Verify with docker images | grep my-jupyter that the exact tag exists locally.","If you intended auto-build behavior, omit the custom image name so the default image is built instead.","If the tag was mistyped, correct it to match the locally built tag."],"exampleFix":"# before\nserver = DockerJupyterServer(custom_image_name=\"mymage-typo\")\n\n# after\n# docker build -t my-jupyter .\nserver = DockerJupyterServer(custom_image_name=\"my-jupyter\")","handlingStrategy":"validation","validationCode":"import docker\n\ndef image_exists_locally(image_name: str) -> bool:\n    try:\n        docker.from_env().images.get(image_name)\n        return True\n    except docker.errors.ImageNotFound:\n        return False\n\nassert image_exists_locally(\"my-jupyter\"), \"build/pull the image before starting\"","typeGuard":null,"tryCatchPattern":"try:\n    server = DockerJupyterServer(custom_image_name=name)\nexcept ValueError as e:\n    if \"does not exist\" in str(e):\n        raise SystemExit(f\"Run `docker build -t {name} .` first\") from e\n    raise","preventionTips":["Add a CI step that builds required images before running the test suite.","Document required local images in the project README or setup script."],"tags":["docker","image","jupyter","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}