Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker - using python image, add the non-free Debian repo?

Im using a python image in docker and have added some dependencies as per the below:

RUN apt-get update -y \
    && apt-get install -y apt-utils libsasl2-dev python3-dev libldap2-dev libssl-dev libsnmp-dev snmp-mibs-downloader

I'm getting an error

E: Package 'snmp-mibs-downloader' has no installation candidate

Which after searching is because I need a non-free repo adding as per: http://installion.co.uk/debian/wheezy/non-free/s/snmp-mibs-downloader/install/index.html

I believe I need to edit /etc/apt/sources.list and add the below:

deb http://http.us.debian.org/debian jessie main contrib non-free
deb http://security.debian.org jessie/updates main contrib non-free

but how do I do that via a docker file?

like image 765
AlexW Avatar asked Aug 25 '17 09:08

AlexW


People also ask

How to create Docker image with Python application?

Dockerfile contains instructions to prepare Docker image with our Python Application. Following is the content of Dockerfile. FROM python COPY . /src CMD ["python", "/src/PythonExample.py"] 4. Build Docker Image Run the following command in Terminal, from python-application directory, to create Docker Image with Python Application.

Is there a Python version of Docker?

Docker has a series of “official” Docker base images based on various Linux distributions, and also base images that package specific programming languages, in particular Python.

Can I use Debian 10 as a docker base image?

The RedHat Universal Base Image allows you to use it as a Docker base image. Debian 10 (“Buster”) was released on July 2019, and will be supported until 2024. It’s usable in Docker via the debian:10 image. Previous versions of this article covered CentOS, but CentOS is no longer a long-term stable operating system.

What is a Docker Hub repository?

Docker Hub repositories allow you share container images with your team, customers, or the Docker community at large. Docker images are pushed to Docker Hub through the docker push command. A single Docker Hub repository can hold many Docker images (stored as tags ).


2 Answers

While this is the right command,

sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list

If you're going to do this you should do this as part of the rest of your first-image,

RUN \
  sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list \
  && apt-get -q update                                              \
  && apt-get -qy dist-upgrade                                       \
  && apt-get install -qy foobar                                     \
  && foobar whatever                                                \
  && apt-get -qy --purge remove foobar                              \
  && apt-get clean                                                  \
  && rm -rf /var/lib/apt/lists

The above shows this command in the full flow with the rest of the apt stuff.

like image 158
NO WAR WITH RUSSIA Avatar answered Oct 19 '22 04:10

NO WAR WITH RUSSIA


The same way you would do to add the non-free component to your sources.list. Edit the /etc/apt/sources.list file in your Dockerfile and replace the line that looks like:

deb http://http.us.debian.org/debian jessie main contrib

by

deb http://http.us.debian.org/debian jessie main contrib non-free

You can do that in the Dockerfile with a command like

sed -i "s#deb http://http.us.debian.org/debian jessie main contrib non-free#deb http://http.us.debian.org/debian jessie main contrib non-free#g" /etc/apt/sources.list

And same for security.debian.org.

like image 43
Anis Avatar answered Oct 19 '22 03:10

Anis