I came across a strange situation I try to understand.
Given the following:
entrypoint.sh (echo line was added during debugging, and resulted in discovering this)
#!/bin/bash
set -e
# echo "COMMAND: $@"
exec "$@"
Dockerfile
FROM ruby:2.4.10 AS development
RUN apt-get update && \
apt-get install -y apt-utils && \
apt-get install -y dumb-init && \
apt-get install -y tzdata && \
apt-get install -y libpq-dev
ENV LANG="C.UTF-8"
WORKDIR /app
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "-p", "3000"]
FROM development
ADD Gemfile Gemfile.lock .ruby-version ./
RUN bundle config frozen true && bundle install --jobs 5 && bundle config frozen false
COPY . ./
ARG SENTRY_RELEASE=${SENTRY_RELEASE}
ENV SENTRY_RELEASE="${SENTRY_RELEASE}"
We normally build our images in a CI-pipeline, that uses the last version of the image as a cache-source to speed up things: docker build -f Dockerfile -t ${BASE_IMAGE_NAME} --build-arg="SENTRY_RELEASE=${CI_COMMIT_SHORT_SHA}" --cache-from ${CACHE_IMAGE_NAME} .
Though, now (and I think the Caching is the issue) suddenly the command changes.
When I do docker inspect $image
I see:
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"bundle\" \"exec\" \"rackup\" \"--host\" \"0.0.0.0\" \"-p\" \"3000\"]"
]
Instead of the expected (all our other images have this):
"Cmd": [
"bundle",
"exec",
"rackup",
"--host",
"0.0.0.0",
"-p",
"3000"
]
When I build the image without Cache (--no-cache), the command looks as expected. And makes it harder to test. This tells me it is the cache. Though as it has not yet has been a problem for us in the past, this also makes it strange.
My docker file changed before it happened, and as the base image changed in this change docker should have completely ignored the cache. I am assuming it happens when using the Cache, from the first build image after changing the base image.
Actually, this answer gives some the feeling it is expected to look like the first one. Though it is strange as it changes everything we have generated in the past, and we did not update docker in CI in-between.
When I look at docker history, the history entry to set the command actually also is correct.
<missing> 2 hours ago /bin/sh -c #(nop) CMD ["bundle" "exec" "rackup" "--host" "0.0.0.0" "-p" "3000"] 0B
The output of the echo command in the entrypoint.sh looks like this in the kubernetes pod:
COMMAND: /bin/sh -c #(nop) CMD ["bundle" "exec" "rackup" "--host" "0.0.0.0" "-p" "3000"]
So what can cause this? and can in case the first command is correct, why is the default entrypoint not able to process it?
Thanks in advance.