Skip to content

ENTRYPOINT / CMD transformation to exec form is not a no-op #33

@thiagowfx

Description

@thiagowfx

Consider this sample Dockerfile (abridged version of a real-world scenario):

ENTRYPOINT sleep infinity
CMD sleep infinity

Let's run dockerfmt (v0.3.7) in it:

% dockerfmt Dockerfile
ENTRYPOINT ["sleep", "infinity"]
CMD ["sleep", "infinity"]

At first glance, everything looks OK. The problem is that this transformation is not a no-op.

Looking at the docs:

If CMD is used to provide default arguments for the ENTRYPOINT instruction, both the CMD and ENTRYPOINT instructions should be specified in the exec form.

The difference is:

  • the original code yields sleep infinity (correct!)
  • the transformed code yields sleep infinity sleep infinity, which is an error (sleep: no such argument sleep)

One could argue that the original code is odd – the following would be conceptually simpler, and more idiomatic:

ENTRYPOINT ["sleep"]
CMD ["infinity"]

Or even:

ENTRYPOINT ["sleep", "infinity"]

Nonetheless, IMHO dockerfmt should not change the behavior in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions