Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

Multistage docker build for Python distroless image

$
0
0

This is my Dockerfile for distroless image similar to this example

FROM python:3.9-slim AS build-venvRUN python3 -m venv /venv # other installation steps go hereRUN /venv/bin/pip install --upgrade pip setuptools wheel# installing from requirements.txt etc.# Copy the virtualenv into a distroless imageFROM gcr.io/distroless/python3-debian11COPY --from=build-venv /venv /venvENTRYPOINT ["/venv/bin/python3"]

I'm trying to just get into Python shell (with all the dependencies installed), but docker run -it my-distroless gives me this error

docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/venv/bin/python3": stat /venv/bin/python3: no such file or directory: unknown.

But when replacing base image with debian:11-slim everything works as expected.

FROM debian:11-slim AS buildRUN apt-get update && \    apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \    python3 -m venv /venv# the rest is the same

Are there only "compatible" base images for distroless that I should use for my builds or what is the possible reason?


Viewing all articles
Browse latest Browse all 136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>