anthropics / anthropic-quickstarts

A collection of projects designed to help developers quickly get started with building deployable applications using the Anthropic API
MIT License
6.14k stars 763 forks source link

Running Demo Encounters Issues on WSL 2 #101

Open Hezhexi2002 opened 2 days ago

Hezhexi2002 commented 2 days ago

Description: I am currently attempting to run the demo within a WSL 2 environment. Despite configuring my .wslconfig file with the recommended settings (networkingMode=mirrored and hostAddressLoopback=true) from https://github.com/microsoft/WSL/issues/10494, I am encountering difficulties accessing the demo application via http://localhost:8081.

When I initially tried mapping the container's port to localhost:8080, I received an error indicating that the port was already in use:

docker: Error response from daemon: driver failed programming external connectivity on endpoint suspicious_joliot (4d6e890f2e22eb4f19366388765105e795725b20f90b1f55fb61f3bf77680a5c): failed to bind port 0.0.0.0:8080/tcp: Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use.

As a result, I modified the Docker run command to map the container's port to localhost:8081 instead, but the service remains inaccessible from the Windows host.

Steps to Reproduce: Configured .wslconfig file with the following settings:

[experimental]
#autoMemoryReclaim=gradual # 可以在 gradual 、dropcache 、disabled 之间选择
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
sparseVhd=true
hostAddressLoopback=true

Verified that Docker is up to date (docker -v confirms version 27.3.1).

 docker -v                                                                                                                      
Docker version 27.3.1, build ce12230

Ran the Docker container using the command with port 8081:

docker run --rm \
    -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
    -v $HOME/.anthropic:/home/computeruse/.anthropic \
    -p 5900:5900 \
    -p 8501:8501 \
    -p 6080:6080 \
    -p 8081:8081 \
    -it ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

Attempted to access the application through http://localhost:8081. Expected Behavior:

After starting the Docker container, the application should be accessible through http://localhost:8081.

Observed Behavior:

The service seems to be launched successfully but I can't access the http://localhost:8081 from my browser.here is the output and screenshot on browser:

docker run --rm \                                                                                                              ─╯
    -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
    -v $HOME/.anthropic:/home/computeruse/.anthropic \
    -p 5900:5900 \
    -p 8501:8501 \
    -p 6080:6080 \
    -p 8081:8080 \
    -it ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest
Xvfb started successfully on display :1
Xvfb PID: 9
starting tint2 on display :1 ...
starting mutter
starting vnc
PORT=5900
starting noVNC
noVNC started successfully
✨ Computer Use Demo is ready!
➡️  Open http://localhost:8080 in your browser to begin
x11vnc process crashed, restarting...
x11vnc stderr output:
24/10/2024 09:06:21 No client after 60 secs.
24/10/2024 09:06:21 deleted 32 tile_row polling images.
starting vnc
PORT=5900
2024-10-24 09:06:47.965 Did not auto detect external IP.
Please go to https://docs.streamlit.io/ for debugging hints.
x11vnc process crashed, restarting...
x11vnc stderr output:
24/10/2024 09:07:28 No client after 60 secs.
24/10/2024 09:07:28 deleted 32 tile_row polling images.
starting vnc
PORT=5900
x11vnc process crashed, restarting...
x11vnc stderr output:
24/10/2024 09:08:35 No client after 60 secs.
24/10/2024 09:08:35 deleted 32 tile_row polling images.
starting vnc
PORT=5900

image

System Details:

Operating System: Windows 11
WSL Version: 2.2.4.0
Linux Distribution: Ubuntu 20.04
Docker Version: 27.3.1

Is there any additional configuration required in the .wslconfig file or elsewhere to ensure that the services are correctly exposed and accessible from the Windows host? Is the port mapping issue related to the networkingMode=mirrored setting?

Hezhexi2002 commented 1 day ago

By temporarily disabling the mirrored network mode in .wslconfig I solved this problem

Hezhexi2002 commented 1 day ago

7111fc637feae3a65e3802ab0fab043 But I don't have any credit left on my account to test it, and I thought I was getting a $5 credit from the Anthropic:-(