Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2.3K
Views
Docker node:8.16.0-alpine Error: not found: python2

I need run npm rebuild node-sass --force inside my docker container

But i got an error (even after i install python already)

Error: Can't find Python executable "python", you can set the PYTHON env variable.

This is my Dockerfile

FROM node:8.16.0-alpine

RUN mkdir /app
WORKDIR /app

# --no-cache: download package index on-the-fly, no need to cleanup afterwards
# --virtual: bundle packages, remove whole bundle at once, when done
RUN apk --no-cache --virtual build-dependencies add \
    python \
    make \
    g++ \
    bash \
    && npm install \
    && apk del build-dependencies

RUN npm install -g nodemon

COPY package.json package.json
COPY client/package.json client/package.json

RUN npm install
RUN npm run install:client
RUN npm uninstall node-sass && npm install node-sass
RUN npm rebuild node-sass --force

COPY . .

LABEL maintainer="Varis Darasirikul"

VOLUME ["/app/public"]

CMD npm run dev

This my docker-compose

version: '3'

services:
  web:
      build: '.'
      container_name: node-web
      # env_file:
        # - '.env'
      ports:
        - '80:8000'
        - '5000:5000'
        - '3000:3000'
      volumes:
        - '.:/app'
      networks:
        - front-tier
        - back-tier
      # depends_on:
        # - redis
        # - db

networks:
  front-tier:
  back-tier:

Even when i run

docker-compose up --build --force-recreate

Still not working

How to fix this?

Thanks!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The problem is that Python is simply not installed.

Your parent image, node:8.16.0-alpine doesn't include Python. You can verify this:

> docker run -it node:8.16.0-alpine sh
/ # python
sh: python: not found

The misunderstanding might come from the fact that you are temporarily installing python on this line:

RUN apk --no-cache --virtual build-dependencies add \
    python \
    ...

It's added to the virtual package build-dependencies, but just after npm install completes, you run apk del build-dependencies which removes Python again!

Just move the line where you uninstall build-dependencies to after you have done all npm rebuild stuff and I think it will work.

over 4 years ago · Santiago Trujillo Report

0

Because you are using alpine image which is a small image that doesn't include python. You can install python by running apk add and remove it after you have installed node modules.

FROM node:alpine

RUN apk add --no-cache --virtual .gyp \
        python \
        make \
        g++ \
    && npm install \
    && apk del .gyp

More read: https://github.com/nodejs/docker-node/issues/282

over 4 years ago · Santiago Trujillo Report

0

An alternate solution exists using bcryptjs. Performance may not mater much however work using instead of applying workarounds!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!