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.
Related
I am trying to build a new image in Docker Compose but the following problem occurs
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apt/apt-utils_2.4.7_amd64.deb 404 Not Found [IP: ]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get install -y apt-utils' returned a non-zero code: 100
ERROR: Service 'nginx-service' failed to build : Build failed
In my Dockerfile I'm running: RUN apt-get install -y apt-utils and with --fix-missing.
None of the related questions or other solutions helped me and I've been stuck for quite a while. What am I missing?
Thanks!
EDIT: The whole Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y nginx
RUN apt-get clean
RUN apt-get install -y curl
RUN apt-get install -y unzip
RUN apt-get install -y wget
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y php php-xml php-curl php-fpm php-mysql
RUN apt-get install -y apt-utils --fix-missing
RUN apt-get install -y php-zip --fix-missing
RUN apt-get install -y php-gd --fix-missing
RUN apt-get install -y mysql-server
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN apt-get install -y nano
RUN apt-get install -y mc
RUN apt-get install -y systemctl
RUN systemctl start nginx.service
usually , when we are building a new image, we use update then install like this
RUN apt-get update && apt-get install -y apt-utils
This will update apt source list and will make the package available to install.
Addibg this to your Dockerfile should fix the issue.
If you want to install many at once you can add the packages like the following :
RUN apt-get update && apt-get install -y \
bzr \
cvs \
git \
mercurial \
subversion \
Building the image like this:
docker-compose build --no-cache
worked for me
This is for an Airflow project, and we're starting with this Dockerfile, which itself seems to start with the debian:buster-slim image.
This post suggested to run the following:
sudo apt install dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl
curl -fsSL https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
sudo add-apt-repository 'deb https://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main'
sudo apt update
sudo apt install mongodb-org
however when we add RUN apt install dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl to the Dockerfile, we get the errors:
E: Unable to locate package dirmngr
E: Package 'gnupg' has no installation candidate
E: Unable to locate package software-properties-common
What should we add to this Dockerfile in order to properly install mongodb to be able to use mongoimport command?
Seems like the following is doing the trick:
RUN apt-get update && apt-get install -y gnupg software-properties-common
RUN curl -fsSL https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
RUN add-apt-repository 'deb https://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main'
RUN apt-get update
RUN apt-get install -y mongodb-org
RUN mongo --version
RUN mongoimport --version
Last 2 lines to test that the first 5 lines worked. Initially ran into issues installing gnupg and software-properties-common but the -y flag and the apt-get update beforehand helped. Everything seems good so far with this.
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.
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
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.