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

from faker import Faker

from ray import serve

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 /serve_app/

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 to the run command and access the server from the host machine at

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

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.