Docker build failed: add-apt-repository -y ppa:bitcoin/bitcoin - docker

This is my dockerfile
FROM ubuntu:rolling
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get -y install software-properties-common && \
add-apt-repository -y ppa:bitcoin/bitcoin && \
apt-get -y update && \
apt-get -y install bitcoin-qt
Whe I run docker build -t test . it's failing because of:
(the output is when I defined seperate RUN steps so I could easily define where it was going wrong).
Step 5/11 : RUN add-apt-repository -y ppa:bitcoin/bitcoin
---> Running in fc64322d6d04
gpg: keybox '/tmp/tmpxbk1iw0_/pubring.gpg' created
gpg: keyserver receive failed: End of file
Failed to add key.
The command '/bin/sh -c add-apt-repository -y ppa:bitcoin/bitcoin' returned a non-zero code: 1
What am I missing? I'm not behind a proxy.

Related

Building a docker container on top of another image... "permission denied"?

I am trying to build an extension of an existing image with FROM and then apt install additional packages on top and do own customizations. I get permission denied and "are you root" messages. Specifically, this is the image I want to extend:
https://hub.docker.com/r/makarius/isabelle
My Dockerfile:
FROM makarius/isabelle:latest
SHELL ["/bin/bash", "-c"]
# Add dependencies
RUN apt-get update && \
apt-get install --yes build-essential && \
apt-get install --yes openjdk-8-jdk && \
apt-get install --yes xterm && \
apt-get install --yes iputils-ping && \
apt-get install --yes vim && \
apt-get install --yes net-tools && \
apt-get -y install xauth && \
apt-get clean
# user
RUN useradd -m foo && (echo foo:foo | chpasswd)
USER foo
# Setup FOO repository
WORKDIR /home/foo
# ... some commands
ENTRYPOINT ["/bin/bash"]
Building it it seems I can't get the ability to install anything. There is no sudo in the image.
root#ub18:/home/x/foo/bar# sudo docker build -t i8:01 -f Dockerfile .
Sending build context to Docker daemon 408.7MB
Step 1/9 : FROM makarius/isabelle:latest
---> da948b0dd494
Step 2/9 : SHELL ["/bin/bash", "-c"]
---> Using cache
---> 64f897ae98ea
Step 3/9 : RUN apt-get update && apt-get install --yes build-essential && apt-get install --yes openjdk-8-jdk && apt-get install --yes xterm && apt-get install --yes iputils-ping && apt-get install --yes vim && apt-get install --yes net-tools && apt-get -y install xauth && apt-get clean
---> Running in 9ec12ecb98e8
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
The command '/bin/bash -c apt-get update && apt-get install --yes build-essential && apt-get install --yes openjdk-8-jdk && apt-get install --yes xterm && apt-get install --yes iputils-ping && apt-get install --yes vim && apt-get install --yes net-tools && apt-get -y install xauth && apt-get clean' returned a non-zero code: 100
I expect to be able to build the extended image from the existing one, with two users defined and all packages installed. I can get by with a single user as well if have to.
The parent image markarius/isabelle switched user to isabelle, you gotta switch it back to root to run apt-get with additional line USER root before that line in your docker file. There's no need to use sudo in docker images since by default you already have root access.

Cant apt install iputils and net-tools in dockerfile

I'm trying to install ping and ifconfig on a docker container. However, when I run this dockerfile, I get the following errors:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libc/libcap2/libcap2_2.25-1.2_amd64.deb Could not connect to archive.ubuntu.com:80 (91.189.88.142). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.152). - connect (111: Connection refused)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libi/libidn/libidn11_1.33-2.1ubuntu1.2_amd64.deb Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/i/iputils/iputils-ping_20161105-1ubuntu3_amd64.deb Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libc/libcap2/libcap2-bin_2.25-1.2_amd64.deb Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libc/libcap2/libpam-cap_2.25-1.2_amd64.deb Unable to connect to archive.ubuntu.com:http:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && apt-get install -y iputils-ping' returned a non-zero code: 100
Here is the Dockerfile I used to try and build the image:
FROM openanalytics/r-base
# system libraries of general use
RUN apt-get update && apt-get install -y \
sudo \
libcairo2-dev \
libxt-dev \
libcurl4-gnutls-dev \
libssl-dev \
libssh2-1-dev \
libssl1.0.0
# system libraries RODBC
RUN apt-get update && \
apt-get install -y --no-install-recommends \
unixodbc \
unixodbc-dev \
unixodbc \
unixodbc-dev \
r-cran-rodbc \
apt-transport-https \
libssl-dev \
libsasl2-dev \
openssl \
curl \
unixodbc \
gnupg \
libc6 libc6-dev libc6-dbg
#.
# mssql drivers
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
#RUN curl https://packages.microsoft.com/config/ubuntu/19.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
RUN ACCEPT_EULA=Y apt-get install mssql-tools
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev mssql-tools
#iptools (ping, ifconfig)
RUN apt-get update && apt-get install -y iputils-ping
RUN apt-get install net-tools
Are the commands to install iputils-ping & net-tools wrong? If I comment-out the iputils line and only install Net-tools alone, I get a similar error.
This is failing because of this line RUN curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
You are replacing the entire file with Microsoft sources, the > operator replaces the file, you need to append to the file with >>, so change the command to RUN curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list >> /etc/apt/sources.list.d/mssql-release.list
The >> appends to a file or creates the file if it doesn't exist.
The > overwrites the file if it exists or creates it if it doesn't exist.
That is why it cannot find the packages. Sources got deleted by the previous command.
Also, you need to do a apt-get update only one time after adding new sources.
And you are missing a -y in the command for installing ping.
Correct command:
RUN apt-get install net-tools -y
Hope this helps. Comment if any further help needed.

Not able to build docker image due to nginx installation error

I am not able to run the following command in the dockerfile.
RUN apt-get update && \
apt-get -y install curl && \
curl http://nginx.org/keys/nginx_signing.key | apt-key add - && \
apt-get update && \
apt-get -y install build-essential libpq-dev nginx supervisor && \
rm -rf /var/lib/apt/lists/*
I get an error like this...
Err:5 http://nginx.org/packages/debian jessie InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62
Reading package lists...
W: GPG error: http://nginx.org/packages/debian jessie InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62
E: The repository 'http://nginx.org/packages/debian jessie InRelease' is not signed.
The command '/bin/sh -c apt-get update && apt-get -y install curl && curl http://nginx.org/keys/nginx_signing.key | apt-key add - && apt-get update && apt-get -y install build-essential libpq-dev nginx supervisor && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
I need to build the docker image in order to run the compose file that I found here...
https://github.com/yoanisgil/easygeoip
use this instead
FROM python:2.7-slim
RUN apt-get update && \
apt-get -y install wget gnupg && \
wget https://nginx.org/keys/nginx_signing.key && \
cat nginx_signing.key | apt-key add - && \
apt-get update && \
apt-get -y install build-essential libpq-dev nginx supervisor && \
rm -rf /var/lib/apt/lists/*
I think your curl did not produced the correct file

Docker container not able to locate Zip packages?

All Ubuntu wiley repositories are added to my Dockerfile, namely main, universe, etc. and are present in my docker image. However, apt-get install in the following Dockerfile is not able to locate any ZIP/UnZIP packages. Error log in the end.
How can I install these common zip packages? At least p7zip-full and rar.
Dockerfile
FROM ubuntu:15.10
CMD ["bash"]
RUN add-apt-repository main && \
add-apt-repository universe && \
add-apt-repository restricted && \
add-apt-repository multiverse
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get dist-upgrade -y && \
apt-get -y autoremove && \
apt-get clean
RUN apt-get install p7zip \
p7zip-full \
p7zip-rar \
unace \
unrar \
zip \
unzip \
xz-utils \
sharutils \
rar \
uudeview \
mpack \
arj \
cabextract \
file-roller \
&& rm -rf /var/lib/apt/lists/*
ERROR THROWN
E: Unable to locate package p7zip-full
E: Unable to locate package unace
E: Unable to locate package unrar
E: Unable to locate package zip
E: Unable to locate package unzip
E: Unable to locate package sharutils
E: Unable to locate package rar
E: Unable to locate package uudeview
E: Unable to locate package mpack
E: Unable to locate package arj
E: Unable to locate package cabextract
E: Unable to locate package file-roller
Tried with this Dockerfile (your Dockerfile without what I told you in my previous comment):
FROM ubuntu:15.10
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get dist-upgrade -y && \
apt-get -y autoremove && \
apt-get clean
RUN apt-get install -y p7zip \
p7zip-full \
unace \
zip \
unzip \
xz-utils \
sharutils \
uudeview \
mpack \
arj \
cabextract \
file-roller \
&& rm -rf /var/lib/apt/lists/*
CMD ["bash"]
It works and it installs zip and p7zip
$ docker build -t mytest .
$ docker run -d -ti --name mytest mytest /bin/bash
$ docker exec -ti mytest /bin/bash
root#f01fc3456a2a:/# zip
root#f01fc3456a2a:/# p7zip
According to Docker best practices
#gile's answer could be improved by:
using apt-get update and install in a single layer
avoiding apt-get
upgrade
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache
Docker sees the initial and modified instructions as identical and
reuses the cache from previous steps. As a result the apt-get update
is not executed because the build uses the cached version. Because the
apt-get update is not run, your build can potentially get an outdated
version of the curl and nginx packages.
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”. You can also
achieve cache-busting by specifying a package version. This is known
as version pinning
Avoid RUN apt-get upgrade and dist-upgrade, as many of the “essential”
packages from the parent images cannot upgrade inside an unprivileged
container. If a package contained in the parent image is out-of-date,
contact its maintainers. If you know there is a particular package,
foo, that needs to be updated, use apt-get install -y foo to update
automatically.
This should be the same as #gile's answer with those best practices applied
FROM ubuntu:15.10
RUN apt-get -y update \
&& apt-get -y autoremove \
&& apt-get clean \
&& apt-get install -y p7zip \
p7zip-full \
unace \
zip \
unzip \
xz-utils \
sharutils \
uudeview \
mpack \
arj \
cabextract \
file-roller \
&& rm -rf /var/lib/apt/lists/*
CMD ["bash"]
*edit
The Docker best practices documentation has been re-arranged.
The advice remains the same. While the part of documentation that the above link anchors to now merely alludes to concerns between build cache and apt-get...
They have added a new section of documentation dedicated to this topic.
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get
in short:
Always combine RUN apt-get update with apt-get install in the same RUN statement

Docker installation debian openjdk-7-jre

I've been trying to install openjdk-7-jre in a docker image. But when I tried to install it I got the following error:
E: Failed to fetch http://security.debian.org/pool/updates/main/o/openjdk-7/openjdk-7-jre-headless_7u111-2.6.7-2~deb8u1_amd64.deb Connection failed [IP: 200.17.202.197 80]
I've been spending a lot of hours trying this. For More details, the instruction in the Dockerfile is:
RUN apt-get update -qq && apt-get install -y -f xvfb wget
RUN sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list && \
apt-get update -qq && \
apt-get install --fix-missing -y -f openjdk-7-jre
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
dpkg --unpack google-chrome-stable_current_amd64.deb && \
apt-get install -f -y && \
apt-get clean && \
apt-get update && \
rm google-chrome-stable_current_amd64.deb
RUN npm install -g protractor mocha jasmine cucumber && \
webdriver-manager update && \
apt-get update
What am I doing wrong?
This is because you are getting an error in the second RUN command, apt-get update -qq. The error is getting buried because of -qq flag (which will quite the error messages. Try without -qq to diagnoise the error)
You can try using below Dockerfile for installing openjdk-7-jre.
FROM ubuntu
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get install --fix-missing -y -f openjdk-7-jre
just added FROM debian:jessie to your dockerfile and successfully built the image. Your problem is your internet connection, Use VPN or Proxy servers to build the image.

Resources