Why can't Docker find a existing package? - docker

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?

#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:
Use a base image that is with ubuntu 18.04 (or later)
Use pip to install the package.
I ended up using option two.

Related

Unable to install perl module in docker file

I am trying to build a lambda layer with Perl support using this prebuilt docker image: https://metacpan.org/pod/AWS::Lambda#Use-Pre-built-Docker-Images
Now I am trying to add this library libtext-roman-perl into the docker image with:
FROM shogo82148/p5-aws-lambda:base-5.36.al2
RUN yum install -y libtext-roman-perl
COPY handler.pl /var/task/
CMD [ "handler.handle" ]
but it is showing No package libtext-roman-perl available.
Is this because there is no repository containing this libray in the environment?
I've tried yum update but it does not resolve this :(
yum install is Fedora/RedHat/CentOS's way to install packages. These projects use the naming convention perl-Foo-Bar for packaging Perl modules. So you could try:
RUN yum install -y perl-Text-Roman
libfoo-bar-perl is the naming convention of Debian/Ubuntu. If you're using one of those distributions (but you don't seem to be), then you'd use apt to install it instead of yum.
RUN apt install libtext-roman-perl

Unable to locate package buildah

I am trying to build Ubuntu image with a possibility to build Docker images on it. The tool that I want to use for it is buildah. However when my docker build executes the installation command: sudo apt-get -y install buildah I get this error: Unable to locate package buildah. My base image is: Zulu OpenJDK from Azul. I can clearly see that the requested package is in the central Ubuntu repo so I really do not understand why it can not find it.
The problem is that the Zulu Dockerfile that you are using is based on Debian Buster (10.0), not Ubuntu. This is indicated by the first line of the file:
FROM debian:buster-slim
Looking at the buildah installation instructions on Github (https://github.com/containers/buildah/blob/master/install.md), we find that buildah is only available in the Bullseye testing branch for Debian not from the default package repo.
Edit your /etc/apt/sources.list file and append the following line:
deb http://deb.debian.org/debian testing main contrib non-free
Run sudo apt update and then you can install buildah using sudo apt-get install buildah

Docker build dependent on host Ubuntu version not on the actual Docker File

I'm facing an issue with my docker build.
I have a dockerfile as follow:
FROM python:3.6
RUN apt-get update && apt-get install -y libav-tools
....
The issue I'm facing is that I'm getting this error when building on ubuntu:20.04 LTS
E: Package 'libav-tools' has no installation candidate
I made some research and found out that ffmpeg should be a replacement for libav-tools
FROM python:3.6
RUN apt-get update && apt-get install -y ffmpeg
....
I tried again without any issue.
but when I tried to build the same image with ffmpeg on ubuntu:16.04 xenial I'm getting a message that
E: Package 'ffmpeg' has no installation candidate
after that, I replace the ffmpeg with libav-tools and it worked on ubuntu:16.04
I'm confused now why docker build is dependant on the host ubuntu version that I'm using and not the actual dockerfile.
shouldn't docker build be coherent whatever the ubuntu version I'm using.
Delete the the existing image and pull it again. Seems you have a old image which may have a different base OS and that is why you are seeing the issue

Docker usage with Odoo 10.0

I need to know how to setup a Docker to implement a container that could help me run an Odoo 10.0 ERP environment in it.
I'm looking for references or some setup guides, even I don't mind if you can paste the CLI below. I'm currently developing in a Ubuntu OS.
Thanks in Advance.......!!!
#NaNDuzIRa This is quite simple. I suggest that when you want to learn how to do something even if you need it very fast to look into the "man page" of the tool that you are trying to use to package your application. In this case, it is Docker.
Create a file name Dockerfile or dockerfile
Now that you know the OS flavor you want to use. Include that at the beginning of the "Dockerfile"
Then, you can add how you want to install your application in the OS.
Finally, you include the installation steps of Odoo for which i have added a link at the bottom of this post.
#OS of the image, Latest Ubuntu
FROM ubuntu:latest
#Privilege raised to install the application or package as a root user
USER root
#Some packages that will be used for the installation
RUN apt update && apt -y install wget
#installing Odoo
RUN wget -O - https://nightly.odoo.com/odoo.key | apt-key add -
RUN echo "deb http://nightly.odoo.com/10.0/nightly/deb/ ./" >> /etc/apt/sources.list.d/odoo.list
RUN apt-get -y update && apt-get -y install odoo
References
Docker
Dockerfile
Odoo

Cannot install packages inside docker Ubuntu image [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last month.
The community reviewed whether to reopen this question last month and left it closed:
Original close reason(s) were not resolved
Improve this question
I installed Ubuntu 14.04 image on docker. After that, when I try to install packages inside the ubuntu image, I'm getting unable to locate package error:
apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package curl
How to fix this error?
It is because there is no package cache in the image, you need to run:
apt-get update
before installing packages, and if your command is in a Dockerfile, you'll then need:
apt-get -y install curl
To suppress the standard output from a command use -qq. E.g.
apt-get -qq -y install curl
From the docs in May 2017 2018 2019 2020 2021 2022
Always combine RUN apt-get update with apt-get install in the same
RUN statement, for example
RUN apt-get update && apt-get install -y package-bar
(...)
Using apt-get update alone in a RUN statement causes caching
issues and subsequent apt-get install instructions fail.
(...)
Using RUN apt-get update && apt-get install -y ensures your Dockerfile installs the latest package versions with no further coding or manual intervention. This technique is known as “cache busting”.
Add following command in Dockerfile:
RUN apt-get update
Make sure you don't have any syntax errors in your Dockerfile as this can cause this error as well. A correct example is:
RUN apt-get update \
&& apt-get -y install curl \
another-package
It was a combination of fixing a syntax error and adding apt-get update that solved the problem for me.
Running apt-get update didn't solve it for me because, it always seemed to read the result of this command from cache and somehow the cache seemed to be corrupted. My suspicion is that, this happens if you have multiple docker containers having the same 'base image' ( for me it was python:3.8-slim).
So, here's what worked for me:
Stopping all Docker containers in the system
docker stop $(sudo docker ps -aq)
Removing all dangling containers
docker container prune
Removing all dangling images
docker image prune
After running these commands the docker build seems to lose the corrupted cache and does a clean apt-get update which fetches the correct package info and the package installations progress as expected.
I found that mounting a local volume over /tmp can cause permission issues when the "apt-get update" runs, which prevents the package cache from being populated. Hopefully, this isn't something most people do, but it's something else to look for if you see this issue.
Out of the blue I started getting this problem. I did this first and it seemed to resolve the problem:
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
I was getting the same error when trying to install cron and nginx-extras in my Dockerfile. I tried all the answers so far and no dice.
I then simply ran
sudo service docker restart
which fixed the issue for me.
This has since been answered but I encountered this issue earlier and none of these steps worked.
The issue, it turns out, was that I had saved a list of packages to install in a separate file. This was saved on a windows machine with a CRLF line separator (\r\n and not just \n). Forcing the line endings to only \n on top of the steps provided in the accepted answer resolved the issue.
I have met the same question when I try to install jre
and
I try the command "apt-get update" and then
try "apt install default-jre" again
and it worked !
I wish it can help you, good luck!
You need to update the package list in your Ubuntu:
$ sudo apt-get update
$ sudo apt-get install <package_name>

Resources