Temporary failure Archlinux Docker - docker

I use a custom dockerfile for my container and i got this error when i try to up my container with docker-compose up -d
Step 4/14 : RUN apt-get update && apt-get install -y libzip-dev wget curl nodejs npm
---> Running in 6007160b4c25
Err:1 http://deb.debian.org/debian bullseye InRelease
Temporary failure resolving 'deb.debian.org'
i test with a dns in /etc/docker/daemon.json
{ "dns" : ["8.8.8.8", "8.8.4.4"]}
but that doesn't work

Related

How can I install curl inside my container?

I have the following Dockerfile
FROM jupyter/scipy-notebook
#RUN apt-get update && apt-get install -y curl
RUN pip install mlflow
RUN pip install sklearn
RUN apt-get update && apt-get install -y curl
When I do
docker build -t mycontainer .
I get
Step 4/4 : RUN apt-get update && apt-get install -y curl
---> Running in 5defd9816a22
Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
The command '/bin/bash -o pipefail -c apt-get update && apt-get install -y curl' returned a non-zero code: 100
I suspect it is something related with not running as a root?
So how can I install curl in my container from the Dockerfile?
EDIT: I applied the answer that I was given.
Unfortunately it did not work
Step 4/7 : USER root
---> Running in aa6a1b7a023f
Removing intermediate container aa6a1b7a023f
---> 59e87b9598b2
Step 5/7 : RUN apt-get update && apt-get install -y curl
---> Running in 4440ce61ebc6
Err:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package curl
The command '/bin/bash -o pipefail -c apt-get update && apt-get install -y curl' returned a non-zero code: 100
EDIT2: I tried it in a different network setup and it worked.
You're seeing a "permission denied" error when apt attempts to create /var/lib/apt/lists/partial. This is because your process isn't running as root; the jupyter/scipy-notebook image is configured to run as non-root user (it runs as user jovyan).
You can change the user under which commands run in your Dockerfile with the USER directive, like this:
FROM jupyter/scipy-notebook
RUN pip install mlflow
RUN pip install sklearn
USER root
RUN apt-get update && apt-get install -y curl
USER jovyan
Note that I've made sure to reset the user back to jovyan after running the apt-get command.
Try to install it with root as it done in official jupyter/scipy-notebook Dockerfile and set it back to $NB_UID: (see user declaration in official base docker image)
USER root
# Install packages you need:
RUN apt-get update && apt-get install -y curl
# Switch back to jovyan to avoid accidental container runs as root
USER $NB_UID
Here is the hierarchy of base docker images used by jupyter/scipy-notebook:
jupyter/base-notebook -> jupyter/minimal-notebook -> jupyter/scipy-notebook

E: Unable to locate package wget in docker

I am trying to build the following dockerfile
FROM php:8.0-apache
RUN apt-get update
# because apparently composer can shell out to unzip? Who knew...
RUN apt-get install wget unzip zip -y
but it failed with the following error
[root#dev svc]# docker build -t wsb -f Dockerfile .
Sending build context to Docker daemon 17.62 MB
Step 1/11 : FROM php:8.0-apache
---> 97f22a92e1d1
Step 2/11 : RUN apt-get update
---> Using cache
---> ddba6cf13bac
Step 3/11 : RUN apt-get install wget unzip zip -y
---> Running in 6fb3e2f37401
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package wget
E: Unable to locate package unzip
E: Unable to locate package zip
The command '/bin/sh -c apt-get install wget unzip zip -y' returned a non-zero code: 100
Existing contents of sources.list file
# deb http://snapshot.debian.org/archive/debian/20210511T000000Z buster main
deb http://deb.debian.org/debian buster main
# deb http://snapshot.debian.org/archive/debian-security/20210511T000000Z buster/updates main
deb http://security.debian.org/debian-security buster/updates main
# deb http://snapshot.debian.org/archive/debian/20210511T000000Z buster-updates main
deb http://deb.debian.org/debian buster-updates main
I am not sure why it's unable to find. Should I add any URL to /etc/apt/sources.list to get this working?
EDIT
Sending build context to Docker daemon 17.62 MB
Step 1/9 : FROM php:8.0-apache
---> 97f22a92e1d1
Step 2/9 : RUN apt-get update && apt-get install wget unzip zip -y
---> Running in 374b1060dfb3
Err:1 http://security.debian.org/debian-security buster/updates InRelease
Temporary failure resolving 'security.debian.org'
Err:2 http://deb.debian.org/debian buster InRelease
Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease
Temporary failure resolving 'deb.debian.org'
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
You've cached a stale update so apt is trying to install these packages from versions that are no longer in the repositories. This is why Docker's best practices mention to not separate these steps:
FROM php:8.0-apache
RUN apt-get update \
&& apt-get install wget unzip zip -y
From the second issue you are now seeing, you have a networking issue within your containers. There are lots of possible causes, including the host not being connected to the network, and networking changing after the docker engine was started. You'd need to provide a lot more debugging (can you reach these nodes from the host, is DNS working, is there a proxy or firewall on the network, etc).

docker-compose build: Retry a step in case it fails for x times?

Due to to partly bad internet in our company we are having issues with building our containers constantly. Lets assume we have our php-fpm container which requires a lot of additional software and has about 60 build steps.
Now when doing docker-compose build --no-cache php-fpm the process quite often quits when e.g. doing apt-get update or installing a certain library.
Output is like this:
Step 29/56 : RUN apt-get update && apt-get -y --no-install-recommends install wkhtmltopdf
---> Running in 7ec583e71349
[...]
Err:1 http://deb.debian.org/debian buster/main amd64 libdouble-conversion1 amd64 3.1.0-3
Could not resolve 'deb.debian.org'
Err:2 http://deb.debian.org/debian buster/main amd64 libpcre2-16-0 amd64 10.32-5
Could not resolve 'deb.debian.org'
[.....]
ERROR: Service 'php-fpm' failed to build: The command '/bin/sh -c apt-get update && apt-get -y --no-install-recommends install wkhtmltopdf' returned a non-zero code: 100
So I wonder if there is a possibility to tell docker to try a step or even certain steps for like three times before quitting the build process?

Failing to fetch package from cdn-fastly.deb.debian.org in docker buid

Dockerfile
FROM debian:stretch
RUN apt-get update && apt-get install -yq --no-install-recommends --force-yes --fix-missing\
curl \
git \
openjdk-8-jdk \
maven \
python2.7 python2.7-setuptools \
python3 python3-setuptools \
r-base \
r-base-core && \
rm -rf /var/lib/apt/lists/*
On building this Dokerfile, I got error:
W: --force-yes is deprecated, use one of the options starting with --allow instead.
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/pool/main/libp/libpsl/libpsl5_0.17.0-3_amd64.deb Connection failed
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/pool/main/j/jbigkit/libjbig0_2.1-3.1+b2_amd64.deb Connection failed
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/pool/main/libx/libxmu/libxmuu1_1.1.2-2_amd64.deb Connection failed
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/pool/main/p/plexus-cli/libplexus-cli-java_1.2-5_all.deb Connection failed
E: Aborting install.
I used debian mirrors from #atline's answer and it worked for me.
Just want to add an example. For India, I added below step in Dockerfile
RUN echo \
'deb http://mirror.cse.iitk.ac.in/debian/ stretch main\n \
deb http://security.debian.org/debian-security stretch/updates main\n \
deb http://mirror.cse.iitk.ac.in/debian/ stretch-updates main\n' \
> /etc/apt/sources.list
From the source list, I guess this related to different site visit to deb.debian.org:
$ docker run --rm -it debian:stretch cat /etc/apt/sources.list
# deb http://snapshot.debian.org/archive/debian/20190708T033000Z stretch main
deb http://deb.debian.org/debian stretch main
# deb http://snapshot.debian.org/archive/debian-security/20190708T033000Z stretch/updates main
deb http://security.debian.org/debian-security stretch/updates main
# deb http://snapshot.debian.org/archive/debian/20190708T033000Z stretch-updates main
deb http://deb.debian.org/debian stretch-updates main
Move your steps to http://deb.debian.org/, you can see this:
The server deb.debian.org does not have packages itself, but the name has SRV records in DNS that let apt in stretch and later find places.
So I guess, sometimes it will redirect you to one mirror which may not very situable for you because of your local network limit. As a result, I suggest you directly use a suitable sources.list to replace the original one in image, all availables see all the Debian mirrors, you can choose one which in your country.

docker on freebsd 11.1

I am trying to run docker on FreeBSD 11.1, but I am having issues in building my docker images, for example, if I use https://github.com/dockerfile/ubuntu/blob/master/Dockerfile and build it, I get the following error:
khine#dhegdheer  ~/Sandboxes/docker  docker build -t ubuntu-on-freebsd .
Sending build context to Docker daemon 2.56 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04
14.04: Pulling from ubuntu
ee0f4a516087: Pull complete
d9a62ff590c6: Pull complete
3ce5430e3227: Pull complete
1ded2a02619b: Pull complete
2b0bc23c3028: Pull complete
aacde6a2c2eb: Pull complete
Digest: sha256:f30e8ac4eb1048d60012fbf4791a072152950e3a339dadbd43c4ff8c0e198528
Status: Downloaded newer image for ubuntu:14.04
---> aacde6a2c2eb
Step 1 : RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && apt-get update && apt-get -y upgrade && apt-get install -y build-essential && apt-get install -y software-properties-common && apt-get install -y byobu curl git htop man unzip vim wget && rm -rf /var/lib/apt/lists/*
---> Running in 3bc6b0fe4f31
Err http://archive.ubuntu.com trusty InRelease
Err http://security.ubuntu.com trusty-security InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://archive.ubuntu.com trusty-backports InRelease
Err http://archive.ubuntu.com trusty Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://security.ubuntu.com trusty-security Release.gpg
Could not resolve 'security.ubuntu.com'
Err http://archive.ubuntu.com trusty-backports Release.gpg
Could not resolve 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-backports/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg Could not resolve 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package build-essential
jail: /bin/sh -c sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && apt-get update && apt-get -y upgrade && apt-get install -y build-essential && apt-get install -y software-properties-common && apt-get install -y byobu curl git htop man unzip vim wget && rm -rf /var/lib/apt/lists/*: failed
The command '/bin/sh -c sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && apt-get update && apt-get -y upgrade && apt-get install -y build-essential && apt-get install -y software-properties-common && apt-get install -y byobu curl git htop man unzip vim wget && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1
where as, running normal pull, works, as per https://wiki.freebsd.org/Docker:
khine#dhegdheer  ~/Sandboxes/docker  docker run -t -i ubuntu /bin/bash
root#:/# uname -a
Linux 2.6.32 FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
here is the docker version:
khine#dhegdheer  ~/Sandboxes/docker  docker version
Client version: 1.7.0-dev
Client API version: 1.19
Go version (client): go1.9
Git commit (client): 582db78
OS/Arch (client): freebsd/amd64
Server version: 1.7.0-dev
Server API version: 1.19
Go version (server): go1.9
Git commit (server): 582db78
OS/Arch (server): freebsd/amd64
It looks like the docker container is not able to breakout from the jail, as I am able to go into the jail, as per:
root#dhegdheer:/usr/home/khine/Sandboxes/docker # jls
JID IP Address Hostname Path
13 172.17.0.12 /usr/docker/zfs/graph/8099a1566348
root#dhegdheer:/usr/home/khine/Sandboxes/docker # jexec 13 bash
root#:/# uname -a
Linux 2.6.32 FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
root#:/#
What have I missed? Any advice is much appreciated.

Resources