MultipleInstructionsDisallowed
Table of contents
Output
Multiple CMD instructions should not be used in the same stage because only the last one will be usedDescription
If you have multiple CMD, HEALTHCHECK, or ENTRYPOINT instructions in your
Dockerfile, only the last occurrence is used. An image can only ever have one
CMD, HEALTHCHECK, and ENTRYPOINT.
Examples
❌ Bad: Duplicate instructions.
FROM alpine
ENTRYPOINT ["echo", "Hello, Norway!"]
ENTRYPOINT ["echo", "Hello, Sweden!"]
# Only "Hello, Sweden!" will be printed✅ Good: only one ENTRYPOINT instruction.
FROM alpine
ENTRYPOINT ["echo", "Hello, Norway!\nHello, Sweden!"]You can have both a regular, top-level CMD
and a separate CMD for a HEALTHCHECK instruction.
✅ Good: only one top-level CMD instruction.
FROM python:alpine
RUN apk add curl
HEALTHCHECK --interval=1s --timeout=3s \
CMD ["curl", "-f", "http://localhost:8080"]
CMD ["python", "-m", "http.server", "8080"]