Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2.3K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda