Install pip in docker

前端 未结 4 1875
野的像风
野的像风 2020-12-09 01:01

I\'m not able to install pip in Docker.

Here\'s my Dockerfile:

FROM ubuntu:14.04

# Install dependencies
RUN apt-get update -y
RUN apt-get install -y         


        
4条回答
  •  不知归路
    2020-12-09 01:39

    While T. Arboreus's answer might fix the issues with resolving 'archive.ubuntu.com', I think the last error you're getting says that it doesn't know about the packages php5-mcrypt and python-pip. Nevertheless, the reduced Dockerfile of you with just these two packages worked for me (using Debian 8.4 and Docker 1.11.0), but I'm not quite sure if that could be the case because my host system is different than yours.

    FROM ubuntu:14.04
    
    # Install dependencies
    RUN apt-get update && apt-get install -y \
        php5-mcrypt \
        python-pip
    

    However, according to this answer you should think about installing the python3-pip package instead of the python-pip package when using Python 3.x.

    Furthermore, to make the php5-mcrypt package installation working, you might want to add the universe repository like it's shown right here. I had trouble with the add-apt-repository command missing in the Ubuntu Docker image so I installed the package software-properties-common at first to make the command available.

    Splitting up the statements and putting apt-get update and apt-get install into one RUN command is also recommended here.

    Oh and by the way, you actually don't need the -y flag at apt-get update because there is nothing that has to be confirmed automatically.

    Finally:

    FROM ubuntu:14.04
    
    # Install dependencies
    RUN apt-get update && apt-get install -y \
        software-properties-common
    RUN add-apt-repository universe
    RUN apt-get update && apt-get install -y \
        apache2 \
        curl \
        git \
        libapache2-mod-php5 \
        php5 \
        php5-mcrypt \
        php5-mysql \
        python3.4 \
        python3-pip
    

    Remark: The used versions (e.g. of Ubuntu) might be outdated in the future.

提交回复
热议问题