Localhost not working in the task

I have a working docker image, which I can locally on my machine. Now I wanted to run a task in the concourse which gets this image and run some curl commands against the service running in it.
the command looks like “curl -X GET http://localhost:8081”. But I am getting (7) Failed to connect to localhost port 8081: Connection refused.

Setup: concourse is running in a container(using a concourse-docker file)