fix(computer-use): make Docker ports configurable via environment variables#373
Open
gn00295120 wants to merge 2 commits into
Open
fix(computer-use): make Docker ports configurable via environment variables#373gn00295120 wants to merge 2 commits into
gn00295120 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the Computer Use Demo WebUI breaking under asymmetric Docker port mappings by making the container’s internal service ports and the browser-facing (host) ports configurable via environment variables, and regenerating the landing page at startup with the correct host-side ports.
Changes:
- Introduces
*_PORTand*_HOST_PORTenvironment variables and uses them across startup scripts. - Regenerates the landing page
index.htmlat container startup to embed the correct host-side iframe URLs. - Updates docs to explain custom port mapping configuration.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
computer-use-demo/Dockerfile |
Adds default ENV values for the new port configuration variables. |
computer-use-demo/image/entrypoint.sh |
Exports port env defaults and regenerates static_content/index.html with host-side ports. |
computer-use-demo/image/http_server.py |
Binds the HTTP server to HTTP_PORT from the environment. |
computer-use-demo/image/x11vnc_startup.sh |
Uses VNC_PORT env var for x11vnc bind and readiness check. |
computer-use-demo/image/novnc_startup.sh |
Uses VNC_PORT/NOVNC_PORT env vars for noVNC and readiness check. |
computer-use-demo/image/index.html |
Adds a note about runtime regeneration (but see review comment re: which file is actually regenerated/served). |
computer-use-demo/README.md |
Documents how to use the new port environment variables for different mapping scenarios. |
Comments suppressed due to low confidence (1)
computer-use-demo/image/novnc_startup.sh:21
- The wait loop doesn’t verify that noVNC actually started: if the timeout elapses, the script will still continue and later print a success message. Consider checking
timeout == 0after the loop and exiting non-zero (optionally printing/tmp/novnc.log) when noVNC fails to bind.
timeout=10
while [ $timeout -gt 0 ]; do
if netstat -tuln | grep -q ":${NOVNC_PORT} "; then
break
fi
sleep 1
((timeout--))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
84d269d to
e1b2b71
Compare
scutuatua-crypto
approved these changes
May 2, 2026
…iables Replace hardcoded port numbers (8080, 8501, 5900, 6080) with environment variables (HTTP_PORT, STREAMLIT_PORT, VNC_PORT, NOVNC_PORT). Add HOST_PORT variants (HTTP_HOST_PORT, STREAMLIT_HOST_PORT, NOVNC_HOST_PORT) for asymmetric Docker port mappings where the host port differs from the container port. The landing page index.html is now regenerated at container startup with the correct host-side port numbers so iframe URLs resolve correctly regardless of Docker port mapping. Fixes anthropics#271
e1b2b71 to
763843d
Compare
Author
|
@scutuatua-crypto can you check again ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces hardcoded port numbers with environment variables so the WebUI works correctly with custom Docker port mappings.
Quickstart
Type of Change
Problem
When users map Docker ports asymmetrically (e.g.
-p 9090:8080), the WebUI breaks because iframe URLs and service bindings use hardcoded port numbers (8080, 8501, 5900, 6080).Solution
Introduce environment variables for all ports:
HTTP_PORTSTREAMLIT_PORTVNC_PORTNOVNC_PORTHTTP_HOST_PORTSTREAMLIT_HOST_PORTNOVNC_HOST_PORTThe
*_HOST_PORTvariants are only needed for asymmetric mappings. The landing pageindex.htmlis regenerated at startup with correct host-side ports.Usage
Files Changed
Dockerfileimage/entrypoint.shimage/http_server.pyimage/x11vnc_startup.shimage/novnc_startup.shimage/index.htmlREADME.mdFixes #271