2

I am baffled by a strange issue that I am facing with docker-compose. Pip install is failing for certain packages within requirements.txt file.

docker version

Client:
 Version:           18.09.9
 API version:       1.39
 Go version:        go1.13.4
 Git commit:        1752eb3
 Built:             Sat Nov 16 01:05:26 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.9
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.13.4
  Git commit:       9552f2b
  Built:            Sat Nov 16 01:07:48 2019
  OS/Arch:          linux/amd64
  Experimental:     false

My docker-compose.yml file is:

version: "3.7"

services:

  flask:
    build: ./flask
    container_name: flask
    restart: always
    environment:
      - APP_NAME=MyFlaskApp
    expose:
      - 8080

  nginx:
    build: ./nginx
    container_name: nginx
    restart: always
    ports:
      - "80:80"

The contents of Dockerfile inside ./flask directory is:

# Use the Python3.7.5 image
FROM python:3.7.5

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install the dependencies
RUN pip3 install -r requirements.txt

# run the command to start uWSGI
CMD ["uwsgi", "app.ini"]

My requirements.txt file is (first few lines):

appdirs==1.4.3
apturl==0.5.2
asn1crypto==0.24.0
bcrypt==3.1.6
blinker==1.4

However, when I run docker-compose up command, it fails to install the second package in requirements.txt file.

Building flask
Step 1/6 : FROM python:3.7.5
 ---> fbf9f709ca9f
Step 2/6 : WORKDIR /app
 ---> Using cache
 ---> 39ab3ee34991
Step 3/6 : ADD . /app
 ---> Using cache
 ---> 8968809ff844
Step 4/6 : RUN python3 -m pip install --upgrade pip
 ---> Using cache
 ---> 15f717de5181
Step 5/6 : RUN pip3 install -r requirements.txt
 ---> Running in 7068f09498dc
Collecting appdirs==1.4.3
  Downloading appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
ERROR: Could not find a version that satisfies the requirement apturl==0.5.2 (from -r requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for apturl==0.5.2 (from -r requirements.txt (line 2))
ERROR: Service 'flask' failed to build: The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

I have tried a lot of possible options, but of no use. Some examples being:

  1. Running pip upgrade inside the container.
  2. Updating the DNS in docker as per the thread here.
AKSL
  • 51
  • 2
  • 7
  • It looks like [there isn't an "apturl" package on PyPI](https://pypi.org/search/?q=apturl). Does this work in a non-Docker environment? – David Maze Apr 13 '20 at 16:01
  • 2
    I think this issue is unrelated to docker, you can't pip install apturl because it is not available from pypi. See: https://stackoverflow.com/questions/55910971/could-not-find-a-version-that-satisfies-the-requirement-for-select-requirements/55926018#55926018 – William D. Irons Apr 13 '20 at 16:05
  • @DavidMaze yes it works on the Ubuntu host. Same requirements.txt works outside the docker environment. – AKSL Apr 18 '20 at 07:26

3 Answers3

1

as @WilliamD.Irons already pointed here apturl is a package, you can use :

RUN apt install apturl
RUN pip3 install -r requirements.txt

and remove apturl from your requirements.txt

kederrac
  • 16,819
  • 6
  • 32
  • 55
1

apturl seems to be a client side Ubuntu program for adding support for links like <a href="apt:package">click</a> within a webpage:

The apturl is a graphical mini-program for installing packages from the repository that a user has. It is pre-installed on Ubuntu since version 7.10, and the Firefox and Pidgin programs come with support for it.

Additionally, there are other suggestions that support for this doesn't exisit outside Ubuntu. As the official python:3.7.5 image is based on Debian GNU/Linux this wouldn't be available anyway.

I'd question why this needs to be in the requirements for your Flask app, as you should just be able to write your own python function to generate compatible links within the app. Anyone hitting these links from a supported client (Any Ubuntu box with Firefox according to the above) should be able to successfully process those links.

v25
  • 7,096
  • 2
  • 20
  • 36
1

If using a base container isn't an issue, try the Ubuntu environment and install python. apturl is provided by ubuntu, specifically as it uses apt

# Use the ubuntu
FROM ubuntu:lts


# Set the working directory to /app
WORKDIR /app

# install python and pip, and delete cache
RUN apt update && apt install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*

# Copy the current directory contents into the container at /app
ADD . /app

# Install the dependencies
RUN pip3 install -r requirements.txt

# run the command to start uWSGI
CMD ["uwsgi", "app.ini"]
kek
  • 11
  • 1
  • 1