devcontainers / images

Repository for pre-built dev container images published under mcr.microsoft.com/devcontainers
https://containers.dev
MIT License
1.11k stars 411 forks source link

Is DevContainer Support distroless python docker images? #1076

Closed Natielle closed 1 month ago

Natielle commented 1 month ago

I tried to run the devcontainer with a distroless python image and it not works. More details in slack issue: https://stackoverflow.com/questions/78508477/command-in-container-failed-helpers-check-requirements-sh-in-devcontainer-with

Is it posible to run devcontainer with distroless images?

samruddhikhandale commented 1 month ago

Distroless images are minimal images that do not include a package manager, shell or any other programs you would expect to find in a standard Linux distribution. This is great for security, but it can make things difficult when you need to install additional software or debug issues inside the container.

Dev containers feature relies on certain utilities being available in the container, such as a shell to execute commands and scripts. If these utilities are not available, as is the case with distroless images, you may encounter issues.

The error message you're seeing suggests that the check-requirements.sh script is failing because it can't find a shell to run the script. This is expected behavior with a distroless image, as they do not include a shell.

If you need the security benefits of a distroless image, you might consider using a multi-stage Docker build. In the first stage, you can use a full-featured base image to compile your application and install dependencies. In the second stage, you can copy the compiled application from the first stage into a distroless image. This way, you get a minimal runtime image without sacrificing the developer experience.

However, using a distroless image as a DevContainer base image is not recommended, as it will likely lead to issues due to the missing utilities.

Natielle commented 1 month ago

Thank you soo much about this explanation!