Can't install pip packages inside a docker container with Ubuntu

前端 未结 16 2377
抹茶落季
抹茶落季 2020-11-30 19:07

I\'m following the fig guide to using docker with a python application, but when docker gets up to the command

RUN pip install -r requirements.txt

16条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 19:43

    For me, I was unable to install pip due to the docker's DNS not configured properly. I've tried the above steps, however, configuring docker DNS to Google DNS does not work for my laptop. Docker's DNS can be properly configured only if I set its DNS to my laptop's assigned IP.

    If you use Ubuntu, you can use the following steps to configure your docker's DNS:

    1. Find out your device's assigned IP. You can find this by either

      • Checking the inet addr of your ethernet or wlan in ifconfig
      • Choosing any address in nmcli dev show | grep 'DNS'
    2. Edit dns in /etc/docker/daemon.json (create this file if it doesn't exist previously)

      {
          "dns": ["your_ip_in_step_1"]
      }
      
    3. Restart docker: sudo service docker restart

提交回复
热议问题