Skip to content

Make Docker optional #209

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.

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Make Docker optional #209

wants to merge 8 commits into from

Conversation

husseinmozannar
Copy link
Collaborator

@husseinmozannar husseinmozannar commented Jun 20, 2025

Make docker optional with command

If you are not able to setup Docker, you can run a limited version of Magentic-UI which does not have the ability to execute code, navigate files or display the browser in the interface with the command:

magentic-ui --run-without-docker --port 8081

You can also run Magentic-UI in a command-line-interface:

magentic-cli --work-dir PATH/TO/STORE/DATA

# Defer to self for inside_docker
"inside_docker": self.inside_docker,
}
if self.run_without_docker:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed so that if ran with --run-without-docker it does not get overriden

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes Docker optional by introducing a --run-without-docker flag to disable Docker-dependent features (coder agent, file surfer agent, and live browser view) and propagates the new flag through configuration, CLI commands, backend managers, frontend store, and documentation.

  • Added run_without_docker to MagenticUIConfig, CLI options, HTTP app startup, and dependency injection.
  • Updated browser initialization and agent inclusion logic to respect the new flag.
  • Updated defaults (headless browser), README, and frontend store to reflect optional Docker mode.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/magentic_ui/tools/playwright/browser/utils.py Updated default headless to True for browser resources
src/magentic_ui/task_team.py Modified get_task_team to pass and respect run_without_docker, and conditionally include agents
src/magentic_ui/magentic_ui_config.py Added run_without_docker field and updated default browser_headless
src/magentic_ui/backend/web/managers/connection.py Extended WebSocketManager to accept and store run_without_docker
src/magentic_ui/backend/web/deps.py Passed run_without_docker to init_managers
src/magentic_ui/backend/web/app.py Injected RUN_WITHOUT_DOCKER env var into Uvicorn lifecycle
src/magentic_ui/backend/teammanager/teammanager.py Updated TeamManager to skip browser setup and agent inclusion when run_without_docker
src/magentic_ui/backend/cli.py Added Typer option --run-without-docker and conditional Docker setup
src/magentic_ui/_cli.py Added legacy CLI flag --run-without-docker
frontend/src/components/store.tsx Exposed run_without_docker and browser_headless in frontend config
README.md Documented usage of --run-without-docker and updated command examples
Comments suppressed due to low confidence (3)

src/magentic_ui/backend/web/managers/connection.py:52

  • The docstring lists 'run_without_docker' before 'config', but the init signature orders 'config' before 'run_without_docker'. Please reorder the doc entries to match the signature.
        run_without_docker (bool): Flag indicating if the application is running without docker

src/magentic_ui/task_team.py:201

  • [nitpick] Consider adding unit tests to cover the run_without_docker branch to ensure coder and file_surfer agents are skipped as expected.
    if not magentic_ui_config.run_without_docker:

src/magentic_ui/backend/teammanager/teammanager.py:152

  • [nitpick] Add unit tests to verify that novnc_port and playwright_port are set to -1 when run_without_docker is true, and that no browser is launched.
        if not self.run_without_docker:

husseinmozannar and others added 2 commits June 19, 2025 19:56
Introduced a new toggle for enabling/disabling headless mode for the browser, applicable when running without Docker. Added a tooltip for user guidance.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@matheusmaldaner
Copy link
Collaborator

Got the following error when running the default magentic-ui --port 8081 command and toggling Browser Headless to ON in the General Setting.

To my understanding, when running normally and then turning that setting off, the system tries to look for the mcr.microsoft.com/playwright:v1.51.1-noble image which was never downloaded in this scenario because we did not intend to run it locally.

Two solutions would be to either (1) only show the toggleable option to users if they are running with the --run-without-docker flag (passing the argument to the frontend) or (2) to dynamically download the mcr.microsoft.com/playwright:v1.51.1-noble image if needed. Happy to look into this tomorrow morning!

Error trace below:

2025-06-19 22:57:04.996 | ERROR    | magentic_ui.backend.teammanager.teammanager:_create_team:268 - Error creating team: 404 Client Error for http+docker://localhost/v1.50/containers/create?name=magentic-ui-headless-browser_39431: Not Found ("No such image: mcr.microsoft.com/playwright:v1.51.1-noble")
2025-06-19 22:57:04.996 | WARNING  | magentic_ui.backend.teammanager.teammanager:close:432 - Team manager is not initialized or already closed
ERROR:magentic_ui.backend.web.managers.connection:Stream error for run 162: 404 Client Error for http+docker://localhost/v1.50/containers/create?name=magentic-ui-headless-browser_39431: Not Found ("No such image: mcr.microsoft.com/playwright:v1.51.1-noble")
Traceback (most recent call last):
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/api/client.py", line 275, in _raise_for_status
    response.raise_for_status()
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/requests/models.py", line 1026, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.50/containers/create?name=magentic-ui-headless-browser_39431

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/backend/web/managers/connection.py", line 210, in start_stream
    async for message in team_manager.run_stream(
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/backend/teammanager/teammanager.py", line 306, in run_stream
    _, _novnc_port, _playwright_port = await self._create_team(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/backend/teammanager/teammanager.py", line 217, in _create_team
    await get_task_team(
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/task_team.py", line 256, in get_task_team
    await team.lazy_init()
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/teams/orchestrator/_group_chat.py", line 151, in lazy_init
    await asyncio.gather(
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/agents/web_surfer/_web_surfer.py", line 380, in lazy_init
    await self._browser.__aenter__()
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/tools/playwright/browser/base_playwright_browser.py", line 75, in __aenter__
    await self._start()
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/tools/playwright/browser/base_playwright_browser.py", line 163, in _start
    self._container = await self.create_container()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/src/magentic_ui/tools/playwright/browser/headless_docker_playwright_browser.py", line 90, in create_container
    return await asyncio.to_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/models/containers.py", line 935, in create
    resp = self.client.api.create_container(**create_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/api/container.py", line 440, in create_container
    return self.create_container_from_config(config, name, platform)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/api/container.py", line 457, in create_container_from_config
    return self._result(res, True)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/api/client.py", line 281, in _result
    self._raise_for_status(response)
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/api/client.py", line 277, in _raise_for_status
    raise create_api_error_from_http_exception(e) from e
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matheus/repos/06-19-2025/magentic-ui/.venv/lib/python3.12/site-packages/docker/errors.py", line 39, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation) from e
docker.errors.ImageNotFound: 404 Client Error for http+docker://localhost/v1.50/containers/create?name=magentic-ui-headless-browser_39431: Not Found ("No such image: mcr.microsoft.com/playwright:v1.51.1-noble")

@matheusmaldaner
Copy link
Collaborator

Same error when running magentic-cli --work-dir ./work_dir as CLI now tries to use the headless browser.

@husseinmozannar
Copy link
Collaborator Author

Great catch! Fixed now by ignoring the toggle when running in docker.

Updated the logic for the run_without_docker parameter to default to True and allow configuration from settings_config for browser_headless. This enhances flexibility in managing the application's behavior when not using Docker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants