Anna Bondar
Anna Bondar

Reputation: 33

Can't install python pip to docker container

I'm trying to run a flask app in a docker container. When I try to build a container I get

E: Unable to locate package python-pip
The command '/bin/sh -c apt-get install -y python-pip python-dev build-essential' returned a non-zero code: 100

My Dockerfile is:

FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app 
RUN pip install -r requirements.txt
ENTRYPOINT ['python']
CMD ['app.py']

I've tried to use these commands before installing python-pip, but it didn't help:

RUN apt-get install -y software-properties-common 
RUN add-apt-repository universe 

Upvotes: 2

Views: 11192

Answers (1)

jozo
jozo

Reputation: 4772

You have to use package python3-pip. Your Dockerfile can look like:

FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python3-pip python-dev build-essential
COPY . /app
WORKDIR /app 
RUN pip install -r requirements.txt
ENTRYPOINT ['python']
CMD ['app.py']

Better option is to use directly Python image:

FROM python:3
RUN apt-get update -y && apt-get install -y build-essential
COPY . /app
WORKDIR /app 
RUN pip install -r requirements.txt
ENTRYPOINT ['python']
CMD ['app.py']

Upvotes: 6

Related Questions