docker / roadmap

Welcome to the Public Roadmap for All Things Docker! We welcome your ideas.
https://github.com/docker/roadmap/projects/1
Creative Commons Zero v1.0 Universal
1.46k stars 246 forks source link

Allow Dockerfile build args to apply to HEALTCHECK instruction #598

Open leverage-analytics opened 5 months ago

leverage-analytics commented 5 months ago

Tell us about your request Currently, an ARG can be interpolated in some instructions, such as the COPY instruction. Here's an example:

ARG USER=hello
COPY --chown=${USER}:${USER} . .

Currently, however, an ARG cannot be interpolated in the HEALTHCHECK instruction. Here's an example:

ARG INTERVAL=60
HEALTHCHECK --interval="${INTERVAL}s" CMD some-command ${INTERVAL}

In this example, an INTERVAL ARG equal to 60 would be known to the HEALTHCHECK instruction, and the --interval flag would be interpreted to be 60s.

Which service(s) is this request for? This is applicable to Dockerfiles.

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? As shown in the example, there are HEALTCHECK CMDs that must know one or more options related to the the check. For example, in the case of logging heartbeats to file, some-command (from the example) needs to know how frequently to expect a heartbeat. This could be accomplished, according to the example, by setting an interval ARG that would be passed to the --interval flag as well as an argument to the whatever command is being executed by CMD.

Are you currently working around the issue? Currently, the --interval flag must be set manually (in the Dockerfile, at docker run, or in docker-compose). This always requires specifying the same configuration value at least twice - once for the --interval flag and once as part of the CMD - and possibly more times (if using docker-compose for with different configurations for dev/testing/prod). This is open to user error since it's easy to forget to check that the arguments are in sync with each other.

Additional context Thanks for your consideration!