0

I have an image - which is exporting some metrics of the app once it is ready - that I need to deploy as sidecar on Openshift.

The issue is that, to be ready the app takes some time and in the meantime it would restart few times before being ready leading the deployment to be in a crashing status for a few minutes which is unacceptable. To overcome this, I thought about overriding the entrypoint of the sidecar by adding a sleep.

command: ["/bin/sh"]
args: ["-c", "sleep 20"]

But the sidecar image does not have an sh binary:

stat /bin/sh: no such file or directory

And if I try to add it, I get a permission denied error.

exec /bin/sh: permission denied

I've tried also adding executable permission, running as root and adding libraries to the image, nothing works.

Dockerfile:

FROM nginx-unprivileged AS os-tools
COPY --from=os-tools /bin/sh
COPY --from=os-tools /lib/x86_64-linux-gnu...
gipsy
  • 85
  • 2
  • 15
  • 1
    You most likely lack executable bit set. See answers here -> [Copying files with execute permissions in Docker Image](https://stackoverflow.com/questions/56558570/copying-files-with-execute-permissions-in-docker-image) – Marcin Orlowski Jan 31 '23 at 13:22
  • Still if the image is a different architecture (or compiled against a different shared library, etc) the binary might still not work. A more robust solution is often to use a base image which already contains, or can install, the utilities you need. – tripleee Jan 31 '23 at 13:26
  • By adding 'RUN chmod +x /bin/sh' I get: 'standard_init_linux.go:207: exec user process caused "permission denied"' – gipsy Jan 31 '23 at 13:34
  • Which libraries exactly did you `COPY --from=os-tools`? On a bare Ubuntu image `ldd /bin/sh` shows three libraries (`linux-vdso.so.1`, `/lib/x86_64-linux-gnu/libc.so.6`, and `/lib64/ld-linux-x86-64.so.2`; for the first, see also https://stackoverflow.com/questions/58657036/where-is-linux-vdso-so-1-present-on-the-file-system) – tripleee Feb 01 '23 at 06:57
  • Yes, I copied those. – gipsy Feb 01 '23 at 14:03

0 Answers0