Docker Community Forums

Share and learn in the Docker community.

Unable to locate pip

Sending build context to Docker daemon 3.072kB
Step 1/8 : FROM ubuntu
—> 1d622ef86b13
Step 2/8 : RUN apt-get update
—> Using cache
—> b5f51035e7d4
Step 3/8 : RUN apt-get install -y python
—> Using cache
—> d1fe9ba22caa
Step 4/8 : RUN apt-get update
—> Using cache
—> f3bb617d6e03
Step 5/8 : RUN apt-get -y install pip
—> Running in fb28cbfe6447
Reading package lists…
Building dependency tree…
Reading state information…
E: Unable to locate package pip
The command ‘/bin/sh -c apt-get -y install pip’ returned a non-zero code: 100

Well, the second RUN apt-get updateis unnecessary …
I’m not sure which version of Ubuntu you’re pulling, but you might try a …

RUN apt-get install -y python-pip

…instead.

I have tried that also but that is also not working . (Not using second apt-get update
Even I have tried to pull lower version of ubuntu that didn’t work

What Ubuntu image you’re pulling ? latest ?

20.04
And
Also tried with 18.04

Use

RUN apt-get install -y python3-pip

That will work.

My test Dockerfile:

FROM ubuntu:20.04
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y python3-pip
CMD tail -f /dev/null

# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
pip-test                   0.1                 1dd1ea8809d7        17 seconds ago      388MB

# docker run -d pip-test:0.1

 docker exec -it b0ea8afe6bbd /bin/bash
root@b0ea8afe6bbd:/# pip3

Usage:
  pip3 <command> [options]

Commands:
  install                     Install packages.
...

really thank you. My issue is finally solved.