m-sabu
m-sabu

Reputation: 21

python3 nodejs docker images

I am working with a django angular project. I am using python3 so I want a container where node 6.4.0 and python3 will be installed. I have node:6.4.0 and python:3.4 images in my docker.

Now I want another images named py3node. I am trying this way:

  1. Dockerfile:

    FROM node:6.4.0
    FROM python:3.4
    
  2. docker build -t py3node

    output:
    
    Sending build context to Docker daemon 8.192 kB
    Step 1 : FROM node:6.4.0
    ---> 800da22d0e7b
    Step 2 : FROM python:3.4
    ---> 93bc8e41eb8c
    Successfully built 93bc8e41eb8c
    

Then I run:

docker run -it py3node /bin/bash

root@092724f514:/# node -v

output:
bash: node: command not found

But python3 works. Why node:6.4.0 is not working?

Upvotes: 2

Views: 11082

Answers (3)

Jeba Ranganathan
Jeba Ranganathan

Reputation: 582

You must choose one image and install everything on top of it. In your case I would do it like:

Dockerfile

FROM node:6.4.0
RUN apt-get update || : && apt-get install python -y
RUN apt-get install python3-pip -y

Upvotes: 5

sandyiit
sandyiit

Reputation: 1705

You can refer to : node:7.9-alpine unable to build package due python is not installed

All you need to is to add the following to your DockerFile

RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python
RUN npm install --quiet node-gyp -g

Upvotes: 1

Matthew
Matthew

Reputation: 11347

You can't combine images like this and expect it to work! (Using multiple FROM directives is hazardous and should probably be removed).

You either want to start with a generic image (ubuntu? alpine?) and install python and node, or start with a django friendly image here maybe?. I'd look at how other django+docker projects are doing things.

Upvotes: 4

Related Questions