ronilk
ronilk

Reputation: 372

Need to install rpm package inside docker container without internet connectivity

I have a machine which has no internet connectivity and no access to any docker repository (so no image pulls are possible). I want to install memcached and I have the .rpm file available.

When I want to install on the host machine I execute the command rpm -ivh memcached-1.4.15-10.el7_3.1.x86_64.rpm . But I suppose that is because the rpm package manager comes pre-installed on the host OS.

In the docker container I load the .rpm file and in the dockerfile I include the command RUN rpm -ivh memcached-1.4.15-10.el7_3.1.x86_64.rpm. After that I get the following error:

/bin/sh: 1: rpm: not found The command '/bin/sh -c rpm -ivh /home/memcached-1.4.15-10.el7_3.1.x86_64.rpm' returned a non-zero code: 127

I suppose that is because in a docker container the OS has the bare minimum installation. So how do I install the rpm package manager inside the container without internet connection? Is there an installable file for it.

I understand it is not the best practice to not use a central repository for images. Want to know if installing without internet is even possible?

I am creating the container on a CentOS machine right now. And following is the dockerfile:

FROM microsoft/dotnet:2.0-runtime

WORKDIR /home
#mempkgtest folder contains the .rpm file
COPY ${source:-mempkgtest} .

RUN rpm -ivh /home/memcached-1.4.15-10.el7_3.1.x86_64.rpm

ENTRYPOINT ["dotnet", "--info"]

Upvotes: 0

Views: 14436

Answers (1)

KamilCuk
KamilCuk

Reputation: 140990

Docker image microsoft/dotnet is build on top of buildpack-deps:jessie-scm (from here) which is build on top debian:jessie (from here and here).

debian does not use rpm package manager, it uses deb format for packages. /bin/sh kindly informs you, that is hasn't found rpm manager by saying /bin/sh: 1: rpm: not found. You can read how to install rpm packages on debian here.

Anyway, why don't you use deb file and dpkg package manager? You can find memcached pacakge for debian jessie here. You can do smth like this in your dockerfile:

ADD http://ftp.us.debian.org/debian/pool/main/m/memcached/memcached_1.4.21-1.1+deb8u1_amd64.deb
RUN dpkg -i memcached_1.4.21-1.1+deb8u1_amd64.deb

And remember, you will need to copy dependencies too.

Why don't you make your docker image on machine with internet access, than export docker image using docker export and then copy and import it on your destination machine? Such way is simpler and apt-get will resolve and install all memcached dependencies for you.

Upvotes: 3

Related Questions