Home > Software design >  How to check my healthcheck in falcon using Docker image
How to check my healthcheck in falcon using Docker image

Time:01-26

I am learning Dockerfile and I have a following problem.

my app.py contains healthcheck:

import falcon

class Ping:
    def on_get(self, req, resp):
        """Health check."""
        resp.status = falcon.HTTP_OK


app = application = falcon.API()
app.add_route("/pozice_skladApi/v1/healthcheck", Ping())

I successfully create a Docker image:

enter image description here

When I run the image it seems that it is listening at enter image description here

But I would like to run the healthcheck and when I try wget http://0.0.0.0:80/pozice_skladApi/v1/healthcheck I got :

enter image description here

What I am doing wrong, please? Thanks a lot.

CodePudding user response:

Listening at: http://0.0.0.0:80 means that your program has "bound" to 0.0.0.0, which means that it'll accept connections from anywhere. 0.0.0.0 isn't a real IP address.

Depending on where you do your healthcheck from, you need to use different addresses. If you're doing the healthcheck from inside the container, you can use http://localhost/pozice_skladApi/v1/healthcheck.

If you're doing it from the host machine, you need to first map port 80 in the container to a free port on your host. If port 8080 is free, you'd add -p 8080:80 on your docker run command, so it'd be something like

docker run -d -p 8080:80 <image name>

Then, from the host, you can reach your healthcheck on http://localhost:8080/pozice_skladApi/v1/healthcheck

  • Related