0

I have a Dockerfile for dockerizing a Node.js app:

FROM node:carbon

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

EXPOSE 80
CMD ["npm","start"]

But I also need to make Python 3 available. As I understand, multiple FROM statements in a Dockerfile will not work, as it only takes the most recent FROM. How can I make both Python3 and Node available inside the same container?

1 Answer 1

4

It is true that you cannot use multiple FROM statements to get node from one base image and python from another.

What I would recommend is to settle on one base image and install the other application via the normal package manager. In general, installing Python 3 should be fairly straightforward, for example:

RUN apt-get update && \
    apt-get install -y python3 && \
    rm -rf /var/lib/apt/lists/*
Sign up to request clarification or add additional context in comments.

4 Comments

RUN apt add --no-cache python3
@fins Thanks, I added the command. Have not set up docker properly on my current machine, but I'll test if it works with the node:carbon base image.
Getting E: Command line option --no-cache is not understood. I am running this on Mac.
apt still warns it doesn't have a stable CLI interface so apt-get is better for scripts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.