Never mind. I created a short example to illustrate it:
# create entrypoint
cat <<EOF > entrypoint.sh
#!/bin/bash
echo "it worked!"
sleep 1000
EOF
# change permission to something non executable
chmod 644 entrypoint.sh
# build the image
docker build . -f - -t entrypoint-test --no-cache --pull --force-rm <<EOF
#syntax=docker/dockerfile:1
FROM debian:stable-slim
COPY --chmod=755 entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EOF
Then I run a container based on the image:
me@docker:~/test/e$ docker run --rm -ti entrypoint-test
it worked!
Now here is the interesting part: it works like a charm on version 26.0.x , but does not on 20.10.x.
Checking it with ls -l confirmed that observation:
docker run -ti --rm --entrypoint bash entrypoint-test -c 'ls -l'
Can you share the output of docker info?
Update: My bad. I missed out on that version 20.10.x didn’t use buildkit as default builder. The --chown argument requires buildkit, which should be enabled by default on all newer docker versions.
Of course, it works with 20.10.x if I explicitly use buildkit:
DOCKER_BUILDKIT=1 docker build . -f - -t entrypoint-test --no-cache --pull --force-rm <<EOF
#syntax=docker/dockerfile:1
FROM debian:stable-slim
COPY --chmod=755 entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EOF