How to run HAProxy in docker with pidfile set?

Hi,
I want to run haproxy (2.0.4) in docker, (non-daemon as I suppose)
and also want haproxy write its pid to pidfile.

The reason behind it is we want to get pid for later service follow,
what is the best practice?

Update:
the docker official haproxy dockerfile adds -db to disable the daemon mode,
but how can I get the pid of to service follow, seriously?

I cannot get why haproxy doesn’t write pid to pidfile when in daemon mode. :frowning:

"
It’s unclear to me how you’re using it and why it’s not running in daemon mode, but you may be interested in looking at the master-worker mode which stays in foreground, and does write to the pid file. This mode was designed for systemd which requires the process to stay in foreground, maybe it matches your needs?
"