Skip to content

Make Docker optional - #209

Merged
husseinmozannar merged 12 commits into
mainfrom
docker_optional
Jun 20, 2025
Merged

Make Docker optional#209
husseinmozannar merged 12 commits into
mainfrom
docker_optional

Conversation

@husseinmozannar

@husseinmozannar husseinmozannar commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

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

This comment was marked as outdated.

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@husseinmozannar

Copy link
Copy Markdown
Contributor Author

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

husseinmozannar and others added 8 commits June 20, 2025 01:00
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.

@matheusmaldaner matheusmaldaner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great fixes and additions that enable Magentic UI to be used by users experiencing Docker difficulties.

@husseinmozannar
husseinmozannar requested a review from Copilot June 20, 2025 22:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 usage optional in Magentic‑UI by introducing a new run_without_docker configuration flag and adjusting related components.

  • Added run_without_docker to configuration, CLI options, and backend managers.
  • Updated browser defaults, team creation, and UI settings to reflect non‑Docker mode.
  • Revised documentation and frontend configuration to support running in limited mode without Docker.

Reviewed Changes

Copilot reviewed 14 out of 14 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 Changed default headless value from False to True to support non‑Docker mode.
src/magentic_ui/magentic_ui_config.py Introduced run_without_docker field and reordered configuration fields.
src/magentic_ui/backend/web/managers/connection.py, deps.py, app.py Propagated new run_without_docker flag to backend components.
src/magentic_ui/backend/teammanager/teammanager.py Modified team creation to bypass browser resource allocation when run_without_docker is enabled.
src/magentic_ui/backend/cli.py, _cli.py Added CLI options to enable running without Docker.
frontend/src/components/store.tsx, GeneralSettings.tsx Updated default configuration and UI settings for non‑Docker mode and headless browser.
README.md Revised instructions to include commands for running Magentic‑UI without Docker.
Comments suppressed due to low confidence (1)

README.md:38

  • [nitpick] Ensure the added non-Docker usage instructions clearly detail the functionality limitations in this mode for end users.
magentic-ui --run-without-docker --port 8081

Comment thread src/magentic_ui/tools/playwright/browser/utils.py
Comment thread src/magentic_ui/magentic_ui_config.py
@husseinmozannar
husseinmozannar merged commit 74cbcfe into main Jun 20, 2025
9 checks passed
@husseinmozannar
husseinmozannar deleted the docker_optional branch June 20, 2025 22:24
stefanoamorelli pushed a commit to stefanoamorelli/magentic-ui that referenced this pull request Jun 29, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: matheusmaldaner <t-mkunzler@microsoft.com>
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.

3 participants