I am trying to convert the below Dockerfile to build off of a distroless base image instead of an alpine image.
FROM alpine:3.7
WORKDIR /
CMD ["/bin/sh", "-c", "--"]
The only problem is that the Deployment resource where this container image is being used has some shell commands, hence i need to install shell into the distroless image. Below is part of the Deployment yaml file:
containers:
- name: my-container
image: {{ .Values.image.acr }}
imagePullPolicy: Always
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 60; done;" ]
So far, I have tried to build the image using multi-stage builds, however, it's still not working for me:
FROM alpine:3.7 as builder
WORKDIR /
CMD ["/bin/sh", "-c", "--"]
FROM
gcr.io/distroless/staticCOPY --from=builder / /bin
When I run the container, i see this error: Error: failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/sh": stat /bin/sh: no such file or directory: unknown.