Skip to content

update network_name problem in env dind(docker in docker)#259

Merged
husseinmozannar merged 6 commits intomicrosoft:mainfrom
dkzjq:fix_network_name_dind
Jul 16, 2025
Merged

update network_name problem in env dind(docker in docker)#259
husseinmozannar merged 6 commits intomicrosoft:mainfrom
dkzjq:fix_network_name_dind

Conversation

@dkzjq
Copy link
Copy Markdown
Contributor

@dkzjq dkzjq commented Jul 14, 2025

Title:

Add default parameter network_name to fix network issues in Docker-in-Docker environments

Description:

This merge request introduces a default parameter network_name to address network accessibility issues encountered in Docker-in-Docker (DinD) environments.

Problem:

In DinD setups, containers often face difficulties accessing other Docker containers due to network configuration problems. This can lead to failures in inter-container communication, impacting the functionality of the system.

2025-07-14 02:29:32.373 | WARNING  | magentic_ui.tools.playwright.browser.base_playwright_browser:connect_browser_with_retry:35 - Retrying connection in 5 seconds: : WebSocket error: connect ECONNREFUSED 127.0.0.1:33754
Call log:
  - <ws connecting> ws://127.0.0.1:33754/53ea5ca65d3cb334830e8201ed0da9f6
  -   - <ws error> ws://127.0.0.1:33754/53ea5ca65d3cb334830e8201ed0da9f6 error connect ECONNREFUSED 127.0.0.1:33754
  -   - <ws connect error> ws://127.0.0.1:33754/53ea5ca65d3cb334830e8201ed0da9f6 connect ECONNREFUSED 127.0.0.1:33754
  -   - <ws disconnected> ws://127.0.0.1:33754/53ea5ca65d3cb334830e8201ed0da9f6 code=1006 reason=

Solution:

By adding the network_name parameter, users can explicitly specify the Docker network to be used, ensuring proper connectivity between containers. This change provides a default value for network_name, simplifying configuration and improving reliability in DinD environments.

Changes:

Added a new parameter network_name with a default value.
Updated relevant documentation and examples to reflect the new parameter.
Tested the changes in a Docker-in-Docker environment to ensure proper functionality.
Testing:
Verified that containers can communicate with each other in a DinD setup using the specified network_name.
Ensured backward compatibility for setups that do not explicitly use the network_name parameter.

Impact:

This change improves the robustness of the system in Docker-in-Docker environments and does not affect existing setups that do not rely on the network_name parameter.

Notes:

Please review the implementation and provide feedback. Let me know if additional tests or adjustments are required.

commit 0046648508d1575191ff97fc534f6551694ff173
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Mon Jul 14 10:37:55 2025 +0800

    update network_name problem in env dind(docker in docker)

commit 8770760463f51ffd5875ffbc3194c86110f49eb7
Merge: c65c815 2b65b2d
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Mon Jul 14 10:31:57 2025 +0800

    Merge branch 'dev_zhangjiaqun' into fix_netowrk_name

commit 2b65b2dca00c0755188bf5b2308930b509691f49
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Mon Jul 14 10:19:26 2025 +0800

    update data folder volume

commit ca0034228ea5575794218d0521b6819a1bb14d08
Author: besthunterhj <adjadas1@hotmail.com>
Date:   Thu Jul 10 19:49:11 2025 +0800

    fix plan learning bug

commit 86395a208609c60d3ed366787690cab2ea06244c
Merge: 88b626c 14fa912
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Thu Jul 10 10:31:27 2025 +0000

    Merge branch 'dev_zhangjiaqun' into 'test'

    增加部署文件,修复 docker network 问题

    See merge request data-algorithm/agents/spirits-magentic-ui!1

commit 14fa91285d1c95b0e0aee872641c44d26e6872c5
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Thu Jul 10 12:40:46 2025 +0800

    update dockerfile

commit c8a142a27750a8c67e2618eef36759107ac4e989
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Thu Jul 10 12:38:39 2025 +0800

    update package version

commit bfb02e1f82504a8c2ce9de44f7d6029037b351dc
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Thu Jul 10 11:54:37 2025 +0800

    update build.sh

commit 8608a3949a16350c64c8bd901484132549e5a60b
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Thu Jul 10 11:53:59 2025 +0800

    修复 inside docker 环境问题,优化 vnc 获取地址,优化docker 默认端口为10000-20000范围

commit 648850005de89b4b1cc6bb95a16895aea71489b1
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 18:28:22 2025 +0800

    update Dockerfile

commit feda105df3757c2000aab156e055f2a8eca0d12a
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 18:04:36 2025 +0800

    add network_name problem

commit 9f1e471b3224eb77e4446a352ff330c51ae8139c
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 16:23:48 2025 +0800

    update docker-compose.yml and entrypoint.sh

commit de658d4cd485a33fe4ea57008120fc98f9991a0c
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:58:10 2025 +0800

    update docker-compose.yml

commit 22534c011a1e2affb702259b358bd54bbe241991
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:51:50 2025 +0800

    update Dockerfile

commit dd1e631c069021c60e442ed0e92229dec6f4998d
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:50:11 2025 +0800

    update docker-compose.yml and Dockerfile

commit 2560617b07222651fce831a8f9806a6412188fa6
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:42:51 2025 +0800

    update docker-compose.yml

commit f39595e11df6ded62ddbfedd5642558d56c79457
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:32:09 2025 +0800

    update docker-compose.yml

commit 3bdf323b4b6458590714ee7b803d17e6871d329b
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:05:19 2025 +0800

    add network_mode: host to docker-compose.yml

commit c1ff3fe6d5b881ae68a349f71b2b324809530b3a
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:02:30 2025 +0800

    update dockerfile

commit e5bf127c5950c74efee3b305eff19c2391088992
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:01:03 2025 +0800

    add README.md to dockerfile

commit 867ef3a57ca1dcd9e2c119e2192b2e078d16ffab
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 15:00:03 2025 +0800

    update dockerfile

commit e1b9c8cbe31f3c20b241e78867814d3ae05d9846
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 14:57:34 2025 +0800

    增加默认的 playwright_port 和 novnc_port

commit 2b942c9fd7a65e90c2fddafd394a74cd9973d610
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 12:31:41 2025 +0800

    update dockerfile and docker-compose.yml

commit 4761e7f9dfe6bf27b695b959800e17a4ddeea7c0
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 12:23:55 2025 +0800

    update Dockerfile

commit 28371af539e00241824cbf7e9478908d24ee253c
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:54:55 2025 +0800

    update Dockerfile

commit 11aae8f490a555f055169f1a4ff1ceff78badd30
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:51:34 2025 +0800

    update Dockerfile

commit 3156711d906ed480807c1b4890c06b428e6514e2
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:45:43 2025 +0800

    update Dockerfile

commit 2be9c7c27600e1e98b34549fdc165b27b3747976
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:27:50 2025 +0800

    update Dockerfile

commit ad96eadf0088d0e888a9a706ca5055f373e71749
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:21:38 2025 +0800

    update Dockerfile

commit f38f71e208df6a20a5e44b4de44ad1be8bf8ad4c
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:10:08 2025 +0800

    update Dockerfile

commit 88b626c651e0e6ba4e78ee941b955da82b6092a6
Author: zhangjiaqun <zhangjiaqun@37.com>
Date:   Wed Jul 9 11:01:18 2025 +0800

    增加 docekr 部署文件
@husseinmozannar husseinmozannar self-requested a review July 14, 2025 18:49
@dkzjq
Copy link
Copy Markdown
Contributor Author

dkzjq commented Jul 15, 2025

@microsoft-github-policy-service agree

@husseinmozannar husseinmozannar requested a review from Copilot July 16, 2025 13:19
@husseinmozannar
Copy link
Copy Markdown
Contributor

Thank you for your PR! I am reviewing things now

Copy link
Copy Markdown
Contributor

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 adds support for configurable Docker network names to resolve connectivity issues in Docker-in-Docker (DinD) environments where containers cannot communicate using default network settings.

  • Introduces a network_name parameter with default value "my-network" across browser configuration classes and utility functions
  • Adds environment variable fallback (NETWORK_NAME) for flexible network configuration
  • Updates frontend browser iframe component to dynamically determine server hostname instead of hardcoding "localhost"

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
vnc_docker_playwright_browser.py Adds network_name parameter to browser configuration class
utils.py Updates utility functions to accept and pass through network_name parameter
task_team.py Passes network_name from config to browser resource creation
magentic_ui_config.py Adds network_name field to main configuration class
plans.py Adds OpenAI API configuration from environment variables
browser_iframe.tsx Updates hostname resolution to use current location instead of hardcoded localhost
Comments suppressed due to low confidence (1)

src/magentic_ui/tools/playwright/browser/vnc_docker_playwright_browser.py:49

  • Missing comma after the network_name parameter assignment to maintain consistency with other parameter assignments in the function call.
        network_name (str, optional): Docker network name for container communication. Default: `my-network`.

Comment thread src/magentic_ui/tools/playwright/browser/utils.py Outdated
Comment thread frontend/src/components/views/chat/DetailViewer/browser_iframe.tsx Outdated
Comment thread frontend/src/components/views/chat/DetailViewer/browser_iframe.tsx Outdated
Comment thread src/magentic_ui/backend/web/routes/plans.py Outdated
Comment thread src/magentic_ui/magentic_ui_config.py Outdated
dkzjq and others added 5 commits July 16, 2025 23:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@husseinmozannar husseinmozannar left a comment

Choose a reason for hiding this comment

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

thank you for your contribution! I did some minor cleanup and merging, notably removed the NETWORK_NAME env variable as I worry the name of this environment variable might be used for other purposes by developers and create conflicts here, this can be set now in the config

@husseinmozannar husseinmozannar merged commit 4ca78b8 into microsoft:main Jul 16, 2025
9 checks passed
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