Home > Software engineering >  apk: not found, even with python:3.9-alpine
apk: not found, even with python:3.9-alpine

Time:05-07

I am trying to build docker image:

FROM python:3.9-alpine

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
...

But, I got this error:

Building app
Step 1/19 : FROM python:3.9-alpine
3.9-alpine: Pulling from library/python
df9b9388f04a: Pull complete
a1ef3e6b7a02: Pull complete
365abad9bce0: Pull complete
92eb277ed3c6: Pull complete
7b5fd7905244: Pull complete
Digest: sha256:602cd35ea12a7abc69078f447be06634700bdea7a2642712f8d21cfc35792df0
Status: Downloaded newer image for python:3.9-alpine
 ---> 9f14ea10b146
Step 2/19 : ENV PYTHONDONTWRITEBYTECODE=1
 ---> Running in dbf77cc82443
Removing intermediate container dbf77cc82443
 ---> 5686b41f46cf
Step 3/19 : ENV PYTHONUNBUFFERED=1
 ---> Running in fef9e4712712
Removing intermediate container fef9e4712712
 ---> 81bbdd0c12ca
Step 4/19 : ENV PATH="/scripts:{PATH}"
 ---> Running in bb1766c06644
Removing intermediate container bb1766c06644
 ---> 56c5312884d4
Step 5/19 : COPY ./Pipfile /Pipfile
 ---> 24cecd178fd0
Step 6/19 : COPY ./Pipfile.lock /Pipfile.lock
 ---> bfa1e72d5b1b
Step 7/19 : RUN apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers
 ---> Running in 8cb3f5f29a79
/bin/sh: apk: not found
ERROR: Service 'app' failed to build: The command '/bin/sh -c apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers' returned a non-zero code: 127

As I know, the most popular issue is using non-Alpine image and trying to access apk manager. But, I can't understand, what's wrong with mine.

CodePudding user response:

I believe u have to add a runtime dependencies inside your docker file. trying adding this command inside your docker file

FROM python:3.9-alpine

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH

#add runtime dependencies
RUN apk add --no-cache

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

CodePudding user response:

The error is here

ENV PATH="/scripts:{PATH}"

Change it to

ENV PATH="/scripts:${PATH}"

You missed a $

  • Related