As documented in https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact, if you combine the "shell form" of CMD
and ENTRYPOINT
, the CMD
specification is omitted:
So you should rather use the "exec form" and write something like this:
…
ENTRYPOINT ["/usr/bin/chamber", "exec", "${ENV}_${SERVICE_NAME}", "-r", "1", "--", "./entrypoint.sh"]
CMD ["java -jar", "-Dspring.profiles.active=docker", "target/my.jar"]
However this won't work as is, because the ${ENV}
and ${SERVICE_NAME}
won't be expanded (as a shell would be required).
So the simplest, proper solution to apply here is to refactor your entrypoint.sh
, or if ever you don't want to change it and still rely on environment variables with an "exec form" ENTRYPOINT
, you could write instead:
…
RUN chmod a+x entrypoint1.sh
ENTRYPOINT ["./entrypoint1.sh"]
CMD ["java -jar", "-Dspring.profiles.active=docker", "target/my.jar"]
with a file
entrypoint1.sh
#!/bin/bash
exec /usr/bin/chamber exec ${ENV}_${SERVICE_NAME} -r 1 -- ./entrypoint.sh "$@"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…