To add a healthcheck to a Dockerfile, you can use the HEALTHCHECK statement. This instruction allows you to define a command that will check the state of the container. In your case, you can add a healthcheck that will check if the Kafka exporter metrics are available on port 9308.