Check if Your Container is Distroless
How to check if the container has a shell
Minimus images are built for security around the paradigm that production images, on principle, should not include a shell whenever possible. This paradigm requires a different approach when debugging. The solution will depend on your environment, whether Kubernetes or Docker, as detailed below.
Kubernetes environment
When there’s no shell…
Try to start a shell in your container
Get an error
The error indicates that the executable file was not found.
Conclusion
The error indicates that your container does not have a shell.
Debugging with ephemeral containers
Ephemeral debug containers are the recommended method for debugging distroless containers in production. Ephemeral debug containers are used to temporarily attach to an existing Pod in order to troubleshoot and inspect running services. Learn more
Docker environment
When there’s no shell…
Try to start a shell in your container
Get an error
The error indicates that no such file or directory exists.
Conclusion
The error indicates that the container does not have a shell.
Mount a debugging container
You can mount debugging tools and take advantage of shared namespaces to use a docker exec
command. Learn more
Another option is to use the Docker Debug utility. Docker Debug is available for signed-in Docker users with a paid, Pro, Team, or Business subscription (ref).