boundless-nail-54052
11/04/2025, 4:33 PMlimited-student-10747
11/04/2025, 4:37 PMlimited-student-10747
11/04/2025, 4:37 PMboundless-nail-54052
11/04/2025, 4:38 PMlimited-student-10747
11/04/2025, 4:39 PMboundless-nail-54052
11/04/2025, 4:39 PMuv run python 03_browser_use_with_docker_sandboxed_server.pyboundless-nail-54052
11/04/2025, 4:39 PMlimited-student-10747
11/04/2025, 4:40 PMnutritious-balloon-65098
11/04/2025, 4:40 PMboundless-nail-54052
11/04/2025, 4:42 PMnutritious-balloon-65098
11/04/2025, 4:44 PM03_browser_use_with_docker_sandboxed_server.py with extra_ports=True, the Docker workspace exposes port 8002 for VNC desktop access, but the agent server inside the container doesn't actually start the VNC service, resulting in the log message:
"Desktop service is disabled"
Root Cause
There's a configuration mismatch:
1. Workspace side: When extra_ports=True is set, the DockerWorkspace exposes ports 8001 (VSCode) and 8002 (VNC) to the host
2. Agent server side: The agent server requires the environment variable OH_ENABLE_VNC=true to actually start the VNC service
3. The gap: The workspace doesn't pass OH_ENABLE_VNC to the container environment, so even though the port is exposed, nothing is listening on it
Reproduction
I created a test script that simulates the agent server startup and confirmed:
⢠Without OH_ENABLE_VNC=true: Config shows enable_vnc: False, desktop service returns None, logs "Desktop service is disabled" ā
⢠With OH_ENABLE_VNC=true: Config shows enable_vnc: True, desktop service is created and enabled ā
Solution
The fix is to modify DockerWorkspace.model_post_init() in openhands-workspace/openhands/workspace/docker/workspace.py to automatically set the required environment variables when `extra_ports=True`:
if self.extra_ports:
flags += ["-e", "OH_ENABLE_VNC=true"]
flags += ["-e", "OH_ENABLE_VSCODE=true"]
I've documented the complete bug analysis in /tmp/bug_reproduction_summary.md and created a test script at /tmp/test_desktop_service.py that demonstrates the issue without requiring Docker.
Would you like me to implement the fix for this bug?
<sub>View full conversation</sub>boundless-nail-54052
11/04/2025, 4:46 PMlimited-student-10747
11/04/2025, 4:55 PMboundless-nail-54052
11/04/2025, 5:49 PMgreen-salesmen-24542
11/04/2025, 9:38 PMlimited-student-10747
11/04/2025, 9:39 PMboundless-nail-54052
11/04/2025, 10:24 PMlimited-student-10747
11/04/2025, 10:27 PMboundless-nail-54052
11/04/2025, 10:27 PMboundless-nail-54052
11/04/2025, 10:32 PMboundless-nail-54052
11/04/2025, 10:37 PM[DOCKER] {"asctime": "2025-11-04 22:34:43,564", "levelname": "INFO", "name": "openhands.agent_server.api", "filename": "api.py", "lineno": 64, "message": "Desktop service
started successfully"}boundless-nail-54052
11/04/2025, 10:39 PM[DOCKER] {"asctime": "2025-11-04 22:34:38,385", "levelname": "INFO", "name": "openhands.agent_server.desktop_service", "filename": "desktop_service.py", "lineno": 78, "me
ssage": "Starting TigerVNC on :1 (1280x800)..."}
[DOCKER] Please be aware that you are exposing your VNC server to all users on the
[DOCKER] local machine. These users can access your server without authentication!
[DOCKER] /usr/bin/xauth: file /home/openhands/.Xauthority does not exist
[11/04/25 23:34:38] INFO $ docker inspect -f '{{.State.Running}}' 813007b46861e02796115ad7ae60259ce3434952e6d038992d6e98d697573880 command.py:27
true
[DOCKER]
[DOCKER] New Xtigervnc server '813007b46861:1 (openhands)' on port 5901 for display :1.
[DOCKER] Use xtigervncviewer -SecurityTypes None :1 to connect to the VNC server.
[DOCKER]
[11/04/25 23:34:39] INFO $ docker inspect -f '{{.State.Running}}' 813007b46861e02796115ad7ae60259ce3434952e6d038992d6e98d697573880 command.py:27
true
[11/04/25 23:34:40] INFO $ docker inspect -f '{{.State.Running}}' 813007b46861e02796115ad7ae60259ce3434952e6d038992d6e98d697573880 command.py:27
true
[DOCKER] {"asctime": "2025-11-04 22:34:41,553", "levelname": "INFO", "name": "openhands.agent_server.desktop_service", "filename": "desktop_service.py", "lineno": 121, "m
essage": "Starting noVNC proxy on 0.0.0.0:8002 -> 127.0.0.1:5901 ..."}
[DOCKER] {"asctime": "2025-11-04 22:34:41,555", "levelname": "INFO", "name": "openhands.agent_server.desktop_service", "filename": "desktop_service.py", "lineno": 143, "m
essage": "noVNC URL: http://localhost:8002/vnc.html?autoconnect=1&resize=remote"}
[11/04/25 23:34:41] INFO $ docker inspect -f '{{.State.Running}}' 813007b46861e02796115ad7ae60259ce3434952e6d038992d6e98d697573880 command.py:27
true
[11/04/25 23:34:42] INFO $ docker inspect -f '{{.State.Running}}' 813007b46861e02796115ad7ae60259ce3434952e6d038992d6e98d697573880 command.py:27
true
[DOCKER] {"asctime": "2025-11-04 22:34:43,563", "levelname": "INFO", "name": "openhands.agent_server.desktop_service", "filename": "desktop_service.py", "lineno": 153, "m
essage": "Desktop started successfully"}
ā¤ļøboundless-nail-54052
11/04/2025, 10:40 PMlimited-student-10747
11/04/2025, 10:40 PMboundless-nail-54052
11/04/2025, 10:41 PM