Search code examples
dockerdockerfileprotocol-buffers

Why can't Docker find a existing package?


I am new at using Docker so this may be obvious for some. I am running Ubuntu 18.04TLS.

I want to install the package "python3-protobuf" inside an image. I try to do this with the following line in the Dockerfile:

...
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        python3-protobuf \
        <some other packages to be installed>
...

When I run 'docker build -t myImageName', I get the message:

E: Unable to locate package python3-protobuf

There are many packages that I am installing but this is the only one that is creating a problem for me.

I know that the package name is correct because in the terminal, when I 'apt search' for it, it is found. Additionally, in the dockerfile I do the recommended 'update' and 'install' steps. So it should be finding it. Any ideas why it does not?


Solution

  • @banuj answered this question.

    The package "python3-protobuf" became available from Ubuntu 18.04 and onward. The base image I took is using ubuntu 16.04.

    I have two way to solve this:

    1. Use a base image that is with ubuntu 18.04 (or later)
    2. Use pip to install the package.

    I ended up using option two.