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?
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.
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.
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.
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 ).
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With