Cannot access K6 Rest API on docker host

I’m trying to build own k6 image using the following Dockerfile.


COPY . .


ENTRYPOINT ["k6", "run", "--linger", "src/script.js"]

After the image is created, I try to run it with the following command:

docker run -p 6565:6565 my-k6-app

But even though k6 is running, I can’t access localhost:6565.
it always generates the message curl: (52) Empty reply from server
Does anyone know why?