How severe does this issue affect your experience of using Ray?
- High: It blocks me to complete my task.
I am trying to set up run rayserve inside a docker container. The server is up and running inside the container but I can’t access the server at localhost:8000 outside the docker container. Based on my understanding, I need to specify a host of 0.0.0.0 when starting the ray server but I couldn’t find a way to do so despite spending hours trying suggested solutions from other threads. Could someone recommend the best way to achieve this with the latest ray image? Thank you!
Here is my docker-compose file:
services:
ray-serve:
container_name: ray-head
build:
context: ./
dockerfile: Dockerfile
ports:
- 8265:8265
- 8000:8000
privileged: true
And here is my Dockerfile:
# Dockerfile
FROM rayproject/ray:nightly-aarch64
# Install any additional packages
RUN pip install ray ray[serve] requests
WORKDIR /app
COPY deployments /app/deployments
ENTRYPOINT ["ray", "start", "--head", "--port=6379", "--dashboard-host=0.0.0.0","--block"]
Here is my server code which is under /deployments
directory.
#serve.py
from ray import serve
from starlette.requests import Request
from typing import Dict
@serve.deployment
class Hello:
def __init__(self):
pass
async def __call__(self, starlette_request: Request) -> Dict:
req = await starlette_request.json()
name = req["name"]
return {"response": f"Hello {name}!"}
serve.run(Hello.bind())
I tried several approaches but none of them work:
- Using
serve run serve:app --host 0.0.0.0
from this thread, I got an error:Error: No such option: --host
- I also tried
serve.start(detached=True, http_options={"host": "0.0.0.0"}
from this thread, but I couldn’t runHello.deploy()
in the end. I got an error saying Deployment object doesn’t have a method named deploy(). - I also tried
serve deploy serve_config.yaml
inside the container but I got an import error:
(base) ray@1ca327ef6946:/app/deployments$ serve status
applications:
app1:
status: DEPLOY_FAILED
...
ModuleNotFoundError: No module named 'serve'