[GH-ISSUE #584] docker HEALTHCHECK fails if command line arguments are given #376

Closed
opened 2026-03-15 14:08:33 +03:00 by kerem · 2 comments
Owner

Originally created by @daggaz on GitHub (Nov 13, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/584

Docker HEALTHCHECK works fine If I run mailpit without any args:

$ MAILPIT=$(docker run -d axllent/mailpit)
$ docker inspect $MAILPIT --format '{{json .State.Health.Status}}'
"healthy"

However, if I run it with a command line arg:

$ MAILPIT=$(docker run -d axllent/mailpit --webroot mailpit)                                      
$ docker inspect $MAILPIT --format '{{json .State.Health.Status}}'
"unhealthy"

If I exec into the container and run the health check command myself:

$ docker exec $MAILPIT /mailpit readyz; echo $?
1

However, if I run the command with the additional arguments there as well:

$ docker exec $MAILPIT /mailpit --webroot mailpit readyz; echo $?
0
Originally created by @daggaz on GitHub (Nov 13, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/584 Docker HEALTHCHECK works fine If I run mailpit without any args: ```bash $ MAILPIT=$(docker run -d axllent/mailpit) $ docker inspect $MAILPIT --format '{{json .State.Health.Status}}' "healthy" ``` However, if I run it with a command line arg: ```bash $ MAILPIT=$(docker run -d axllent/mailpit --webroot mailpit) $ docker inspect $MAILPIT --format '{{json .State.Health.Status}}' "unhealthy" ``` If I exec into the container and run the health check command myself: ```bash $ docker exec $MAILPIT /mailpit readyz; echo $? 1 ``` However, if I run the command with the additional arguments there as well: ``` $ docker exec $MAILPIT /mailpit --webroot mailpit readyz; echo $? 0 ```
kerem closed this issue 2026-03-15 14:08:38 +03:00
Author
Owner

@axllent commented on GitHub (Nov 14, 2025):

@daggaz - there is no way around this issue if you are passing argument flags to Mailpit in the Docker command as the background health check inside of Docker can't detect that (unless you're overwriting the healthcheck command). The solution is to use Docker environment variables instead of argument flags, and the default health check should detect the MP_WEBROOT environment correctly and not need any further adjustment.

docker run -d -e MP_WEBROOT=mailpit axllent/mailpit
<!-- gh-comment-id:3530547208 --> @axllent commented on GitHub (Nov 14, 2025): @daggaz - there is no way around this issue if you are passing argument flags to Mailpit in the Docker command as the background health check inside of Docker can't detect that (unless you're overwriting the healthcheck command). The solution is to use Docker environment variables instead of argument flags, and the default health check should detect the `MP_WEBROOT` environment correctly and not need any further adjustment. ``` docker run -d -e MP_WEBROOT=mailpit axllent/mailpit ```
Author
Owner

@daggaz commented on GitHub (Nov 14, 2025):

That's a shame, as it slightly invalidates the point in having an entrypoint like that.

Makes sense though, and your workaround works.

<!-- gh-comment-id:3532712124 --> @daggaz commented on GitHub (Nov 14, 2025): That's a shame, as it slightly invalidates the point in having an entrypoint like that. Makes sense though, and your workaround works.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#376
No description provided.