[Python] Install Python3 on Node Alpine Docker Image

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I used this Docker file to create an environment for my service:

    FROM node:16.13.2-alpine as packages
    WORKDIR /src
    ARG NPM_TKE

    COPY .npmrc package.json package-lock.json ./
    RUN npm install
    COPY . ./
    COPY ./cucumber.testing.js ./cucumber.js

    RUN npm run swagger
    EXPOSE 8080
    CMD ["npm","run","integration-test" ]


    I installed new package on my service that throws the exception below (it asked for Python).
    Python Error Exception

    Locally, I have installed Python and use npm set config to define Python's ENV PATH - and locally, that works good! Now I need it to work on my docker image :)

    I tried to install python on my node docker image, which means adding a command to my docker file, but I ran into a different exception. For example:

    FROM node:16.13.2-alpine as packages
    RUN apk add python3 //*** ADDED ***
    WORKDIR /src
    ARG NPM_TKE

    COPY .npmrc package.json package-lock.json ./
    RUN npm install
    COPY . ./
    COPY ./cucumber.testing.js ./cucumber.js

    RUN npm run swagger
    EXPOSE 8080
    CMD ["npm","run","integration-test" ]


    Error after adding "RUN apk add python3" #1
    Error after adding "RUN apk add python3" #2

    I saw errors about missing 'make', 'g++', etc., and tried this command instead of the last one, but got other different errors:

    RUN apk update && apk add python3 make g++
    # OR
    RUN apk add --no-cache python3



    Error after adding "RUN apk update && apk add python3 make g++" #1
    Error after adding "RUN apk update && apk add python3 make g++" #2

    What is the problem here? How can I install python on my docker image?

    Continue reading...

Compartilhe esta Página