I'm trying to add the plpython package to my docker container (running an Ubunutu image) using the following command (RUN being the docker command that you can ignore if you don't know Docker):

RUN apt-get install -y postgresql-plpython-$PG_MAJOR=$PG_VERSION

However this gives the following error:

E: Unable to locate package postgresql-plpython-9.4
E: Couldn't find any package by regex 'postgresql-plpython-9.4'
INFO[0005] The command [/bin/sh -c apt-get install -y postgresql-plpython-$PG_MA
JOR=$PG_VERSION] returned a non-zero code: 100

However if I insert this same command into this part of an existing Dockerfile (i.e. I add the line postgresql-plpython-$PG_MAJOR=$PG_VERSION \, the command works.

I don't know much about apt-get, so can someone explain why the package is found in the context of the parent Dockerfile, but not my Dockerfile? What can I do to get the package to be found?

  • I think you should modify the question to make it clearer that you are creating an image using the Postgres image as base image. In the last paragraph you use the term "parent Dockerfile", but before that you speak of an "Ubuntu image" and "an existing Dockerfile", so that's easy to miss. – Andreas Veithen Apr 15 '15 at 9:20

The Dockerfile of the base image has the following instruction:

rm -rf /var/lib/apt/lists/*

This clears the package lists downloaded by apt-get update. That's why you get the error. To solve this problem, execute apt-get update again in your Dockerfile.

  • That sounds like it could be right! I'll check it when I get the chance – Migwell Apr 15 '15 at 9:51

Make sure you bundle your update and install commands. See the official Docker docs on the matter. Docker has various issues with cache layer invalidation that can throw errors otherwise.

RUN apt-get update && apt-get install postgresql-plpython-$PG_MAJOR=$PG_VERSION

You can also silence install output, and clean up apt caches to minimize your image and cache size.

RUN apt-get update -qqy \
 && apt-get install -qqy \
 postgresql-plpython-$PG_MAJOR=$PG_VERSION \
 && rm -rf /var/lib/apt/lists/* /var/cache/apt/*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.