Cannot Make Ray Server Ports Visible in Docker

I want to host a Ray server application in a Docker image. Following the example in Customer Docker Images, I created a Python script called fake.py.

from faker import Faker

from ray import serve

@serve.deployment
def create_fake_email():
    return Faker().email()

app = create_fake_email.bind()

In the same directory I have a Dockerfile.

FROM rayproject/ray:latest

RUN pip install Faker==18.13.0

WORKDIR /serve_app

COPY fake.py /serve_app/fake.py

EXPOSE 8000 8265

ENTRYPOINT ["serve", "run", "fake:app"]

I build the image.

 docker build . -t ray-server

Then I run the image.

docker run -p 8000:8000 -p 8265:8265 ray-server

The ray server starts. From inside the container I can connect to the dashboard on port 8265 and run the server application on port 8000, but neither of these work from the host machine.

curl http://localhost:8000
curl: (7) Failed to connect to localhost port 8000 after 0 ms: Couldn't connect to server
curl http://localhost:8265
curl: (7) Failed to connect to localhost port 8265 after 0 ms: Couldn't connect to server

I’m sure I’m doing all the Docker commands correctly. This appears to be the same as a problem reported for Ray 2.5.0 in the About Dashboard inside Docker post on this board.

Is this a bug? Does anyone have a workaround?

How severely does this issue affect your experience of using Ray?

  • High: It blocks me from completing my task.

I can run the server if I add --host 0.0.0.0 to the run command and access the server from the host machine at http://0.0.0.0:8000/.

CMD ["serve", "run", "server:app", "--host", "0.0.0.0"]

I still can’t see the Ray dashboard. This seems to be the same issue discussed in Ray Dashboard cannot be accessed in the host browser.