简体   繁体   中英

How to check my healthcheck in falcon using Docker image

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:

在此处输入图像描述

When I run the image it seems that it is listening at http://0.0.0.0:80 :

在此处输入图像描述

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:

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM