apt-get install fails aas root inside podman container - docker

My Dockerfile look like this:
FROM python:3-ubuntu20.04
ENV PATH="/opt/venv/bin:$PATH"
ENV ON_DOCKER=1
RUN echo "Acquire::http::Proxy \"http://webproxy.ecorp.com:8080/\";" >> /etc/apt/apt.conf.d/apt.conf
RUN echo "Acquire::https::Verify-Peer \"false\";" >> /etc/apt/apt.conf.d/apt.conf
RUN echo "Acquire::https::Verify-Host \"false\";" >> /etc/apt/apt.conf.d/apt.conf
RUN apt-get update -y --allow-insecure-repositories
# RUN sleep 10
RUN apt-get upgrade -y
RUN apt-get install -y -f --allow-unauthenticated python3-venv
RUN python3 -m venv /opt/venv && \
python3 -m ensurepip && \
pip3 install --no-cache wheel && \
pip3 install --no-cache setuptools_scm
COPY package /package/
RUN cd package/ && \
pip install . && \
cd .. && \
rm -r package/
COPY app/requirements.txt requirements.txt
RUN pip install -r requirements.txt
As you can see I need to work a bit around our proxy server to get to the ubuntu repositories.
I run the "podman build ..." always as root and also the app inside is supposed to run as root.
However I get this strange error:
(Reading database ... 100%
(Reading database ... 14378 files and directories currently installed.)
16:45:07 Preparing to unpack .../python3.8-venv_3.8.10-0ubuntu1~20.04.2_amd64.deb ...
16:45:07 Unpacking python3.8-venv (3.8.10-0ubuntu1~20.04.2) ...
16:45:07 dpkg: error processing archive /var/cache/apt/archives/python3.8-venv_3.8.10-0ubuntu1~20.04.2_amd64.deb (--unpack):
16:45:07 error setting timestamps of '/usr/share/doc/python3.8-venv.dpkg-new': Permission denied
16:45:07 Selecting previously unselected package python3-venv.
16:45:07 Preparing to unpack .../python3-venv_3.8.2-0ubuntu2_amd64.deb ...
16:45:07 Unpacking python3-venv (3.8.2-0ubuntu2) ...
16:45:07 dpkg: error processing archive /var/cache/apt/archives/python3-venv_3.8.2-0ubuntu2_amd64.deb (--unpack):
16:45:07 error setting timestamps of '/usr/bin/pyvenv.dpkg-new': Permission denied
16:45:07 Errors were encountered while processing:
16:45:07 /var/cache/apt/archives/python3.8-venv_3.8.10-0ubuntu1~20.04.2_amd64.deb
16:45:07 /var/cache/apt/archives/python3-venv_3.8.2-0ubuntu2_amd64.deb
16:45:07 E: Sub-process /usr/bin/dpkg returned an error code (1)
16:45:07 Error: error building at STEP "RUN apt-get install -y -f --allow-unauthenticated python3-venv": error while running runtime: exit status 100
I've no explanation why this happens or cause ? There is no SELinux nor AppArmor active ...
I even had a "RUN id" inside the Dockerfile to verify being root.
Any ideas ?

Related

dockerfile does not build due to failed size validation

My dockerfile used to build successfully.
I tried to build today (5 days after successful build) with docker build -t fv ., and kept getting the following error:
failed commit on ref "layer-sha256:7a3de07a56633b9096304d02c47f097f3e28ae6c6dd442d1e7c4d26452ecd90a": "layer-sha256:7a3de07a56633b9096304d02c47f097f3e28ae6c6dd442d1e7c4d26452ecd90a" failed size validation: 581433721 != 600361569: failed precondition
any suggestions what this means and how to correct?
my dockerfile is:
FROM rocker/verse
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends build-essential libpq-dev python3.8 python3-pip python3-setuptools python3-dev
RUN pip3 install --upgrade pip
ADD . ./home/rstudio
ADD requirements.txt .
ADD install_packages.r .
# Miniconda and dependencies
RUN cd /tmp/ && \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3 && \
/root/miniconda3/condabin/conda install -y python=3.7
ENV PATH=$PATH:/root/miniconda3/bin
#RUN npm install phantomjs-prebuilt --phantomjs_cdnurl=http://cnpmjs.org/downloads
# installing python libraries
RUN pip3 install -r requirements.txt
# installing r libraries
RUN Rscript install_packages.r
another reference I got was:
=> => sha256:7a3de07a56633b9096304d02c47f097f3e28ae6c6dd442d1e7c4d26452ecd90a 580.97MB / 600.36MB 1150.8s
------
> [ 1/10] FROM docker.io/rocker/verse#sha256:3b417b991a32cc8bf9c1fa173ec976a5cc65522a76918df61b5c6cf6261e63a5:
Would this be because of an issue with the base image pulled?
I found that docker build would fail with this error, but it would work if I first pulled the failing image with docker pull <image> and then ran docker build.
this was due to security encryption from my local ip.
when tethering, was able to generate the docker image with non problems
On my side, I got something like below
------
> [1/3] FROM docker.io/library/python#sha256:10fc14aa6ae69f69e4c953cffd9b0964843d8c163950491d2138af891377bc1d:
------
failed commit on ref "layer-sha256:049db2c7eb8a5bd3833cac2f58c6c72b481f1a0288a8b20527529c4970b52762": "layer-sha256:049db2c7eb8a5bd3833cac2f58c6c72b481f1a0288a8b20527529c4970b52762" failed size validation: 311296 != 3056504: failed precondition
On my side, I managed to solve this by disconnecting from a VPN I was connected to.

Problems installing msodbcsql17 with Docker

I have a dockerfile to upload some python code on Azure. It has been working for a few months, but today it suddenly stopped working.
The relevant commands in the Dockerfile are:
FROM python:3.9.5
:
:
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17
The error message is that appeared today is:
Err:1 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 msodbcsql17 amd64 17.7.2.1-1
404 Not Found [IP: 104.214.230.139 443]
E: Failed to fetch https://packages.microsoft.com/ubuntu/20.04/prod/pool/main/m/msodbcsql17/msodbcsql17_17.7.2.1-1_amd64.deb 404 Not Found [IP: 104.214.230.139 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17' returned a non-zero code: 100
2021/06/16 20:50:56 Container failed during run: build. No retries remaining.
failed to run step ID: build: exit status 100
I believe this might be related to the .deb files being moved - or that some computer at Microsoft is down?
A good workaround would maybe be to download the relevant msodbcsql17 package directly, but I was unable to find this package in the normal repos?
There seems to be some ongoing trouble with microsoft repos for some linux distributions (including ubuntu and debian). Not clear when this will be fixed.
https://github.com/dotnet/core/issues/6381
https://github.com/MicrosoftDocs/sql-docs/issues/6494
The answer might be related to this post:
https://github.com/dotnet/core/issues/6381
It seems that some Ubuntu repositories are broken.
Hopefully it will be fixed soon...
I Will keep an eye on the resolve, but I have the same issue using:
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
# optional: for bcp and sqlcmd
RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
# optional: for unixODBC development headers
RUN apt-get install -y unixodbc-dev

Docker File Error no such file or directory: unkno

Trying to build a pkt miner image in order to deploy to akash.
Keep getting this error
Error invoking remote method 'docker-start-container':
Error: (HTTP code 400) unexpected -
OCI runtime create failed:
container_linux.go:367: starting container process caused: exec:
"./target/release/packetcrypt":
stat ./target/release/packetcrypt: no such file or directory: unknown```
My Dockerfile
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y \
build-essential \
curl
RUN apt-get update
RUN curl -y --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
RUN apt install make
RUN apt-get -y update
RUN apt-get -y install gcc git
RUN apt-get -y update
RUN git clone https://github.com/cjdelisle/packetcrypt_rs
ENV PATH=$PATH:/usr/local/packetcrypt_RS
CMD [ "~/", ".cargo/bin/cargo", "build", "--release" ]
CMD [ "./target/release/packetcrypt", "ann", "-p", "pkt1qd5skpmelkwvzy5vppqhafvmx0n5kqy97eglp00", "http://pool.pkteer.com" ]
I've tried adding WORKDIR
Can't seem to get rid of the error no matter what I do. I have a feeling im missing something obvious

Dockerfile ADD files fails

I'm stuck on this. I'm building a docker image via the this dockerfile
#
# Nginx Custom Domain Https Dockerfile
#
# Builds an OpenResty nginx image with auto-ssl capabilities
# See: https://github.com/GUI/lua-resty-auto-ssl
#
FROM openresty/openresty:latest-xenial
RUN apt-get update
RUN apt-get install -y apt-transport-https
RUN apt-get install -y --no-install-recommends apt-utils
RUN echo "license_key: 64553f3xxxxxxxxx" | tee -a /etc/newrelic-infra.yml
RUN curl https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | apt-key add -
RUN printf "deb [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt xenial main" | tee -a /etc/apt/sources.list.d/newrelic-infra.list
RUN cat /etc/apt/sources.list.d/newrelic-infra.list
RUN echo "license_key: 64553fxxxxxxxxxxxx" | tee -a /etc/newrelic-infra.yml
RUN cat /etc/newrelic-infra.yml
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq newrelic-infra
....
# there is more but see the issue below
I run it with
docker build -t XXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com/qwilr-codebuild-base:latest .
The output of it is:
Sending build context to Docker daemon 41.47kB
Step
1/19 : FROM openresty/openresty:latest-xenial
....
Step 9/19 : RUN echo "license_key: 64553f38xxxxxxxx" | tee
-a /etc/newrelic-infra.yml
---> Using cache
---> 77cd0ece8528
Step 10/19 : RUN cat /etc/newrelic-infra.yml
---> Using cache
---> 2cb1a27b4d8b
Get:1 https://download.newrelic.com/infrastructure_agent/linux/apt xenial/main amd64 newrelic-infra amd64 1.2.15 [4679 kB]
Fetched 4679 kB in 14s (325 kB/s)
Selecting previously unselected package newrelic-infra.
(Reading database ... 15601 files and directories currently installed.)
Preparing to unpack .../newrelic-infra_1.2.15_amd64.deb ...
Unpacking newrelic-infra (1.2.15) ...
Setting up newrelic-infra (1.2.15) ...
Failed to connect to bus: No such file or directory
dpkg: error processing package newrelic-infra (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
newrelic-infra
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get install -yq newrelic-infra' returned a non-zero code: 100
The problem seems to be that adding the newrelic-infra.yml file just does not work. I've also tried COPY and ADD. Is there something I'm missing which would cause this file to not be there for the following apt-get install command.
I have also run with --no-cache and still get the same error. The key failure I believe is that newrelic-infra install expects the file /etc/newrelic-infra.yml to be there, as highlighted by the line Failed to connect to bus: No such file or directory
Is there a reason why files copied to /etc/ are failing? Is it the base image I'm using?
It looks like it an open issue.
dpkg error processing package newrelic-infra
Also, the package is missing under
linux/apt

Docker npm Not found in debian:jessie20180831

My Dockerfile
FROM debian:jessie-20180831 as builder
ENV BUILD_DEPS "curl git"
COPY . /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
RUN apt-get update && apt-get install curl git sudo --no-install-recommends -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -;\
apt-get install nodejs -y --no-install-recommends;
RUN cd ./client-side \
&& npm install && npm run build;
COPY ./sql ./client-side/dist/
RUN apt-get update && apt-get install ${BUILD_DEPS} -y --no-install-recommends;\
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
dep ensure -update;\
go install;
FROM golang:1.11.1-alpine3.7
RUN mkdir -p /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
COPY --from=builder /go/bin/onlinecode .
COPY --from=builder /go/src/chaochaogege.com/onlinecode/client-side/dist/* .
EXPOSE 8086
ENTRYPOINT ["onlinecode"]
I don't know my happened.
From my view, I install nodejs in RUN layer, and then use npm in another layer after it.
But why not work?
There are some dupicate questions I am sure, but all of them not solve my problem.
I guess maybe npm only can be used in same docker layer? So I change Dockerfile to follow:
FROM debian:jessie-20180831 as builder
ENV BUILD_DEPS "curl git"
COPY . /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
RUN apt-get update && apt-get install curl git sudo --no-install-recommends -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -;\
apt-get install nodejs -y --no-install-recommends;\
npm --version; \
cd ./client-side \
&& npm install && npm run build;
COPY ./sql ./client-side/dist/
RUN apt-get update && apt-get install ${BUILD_DEPS} -y --no-install-recommends;\
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
dep ensure -update;\
go install;
FROM golang:1.11.1-alpine3.7
RUN mkdir -p /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
COPY --from=builder /go/bin/onlinecode .
COPY --from=builder /go/src/chaochaogege.com/onlinecode/client-side/dist/* .
EXPOSE 8086
ENTRYPOINT ["onlinecode"]
But also get result
npm not found
Error log
Step 6/15 : RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -; apt-get install nodejs -y --no-install-recommends; npm --version; cd ./client-side && npm install && npm run build;
---> [Warning] Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
---> Running in 2788863ccf8a
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libc-ares2 libv8-3.14.5
The following NEW packages will be installed:
libc-ares2 libv8-3.14.5 nodejs
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1990 kB of archives.
After this operation, 7495 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian/ jessie/main libc-ares2 amd64 1.10.0-2+deb8u2 [72.5 kB]
Get:2 http://deb.debian.org/debian/ jessie/main libv8-3.14.5 amd64 3.14.5.8-8.1 [1269 kB]
Get:3 http://deb.debian.org/debian/ jessie/main nodejs amd64 0.10.29~dfsg-2 [648 kB]
[91mdebconf: delaying package configuration, since apt-utils is not installed
[0mFetched 1990 kB in 1s (1874 kB/s)
Selecting previously unselected package libc-ares2:amd64.
(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 9841 files and directories currently installed.)
Preparing to unpack .../libc-ares2_1.10.0-2+deb8u2_amd64.deb ...
Unpacking libc-ares2:amd64 (1.10.0-2+deb8u2) ...
Selecting previously unselected package libv8-3.14.5.
Preparing to unpack .../libv8-3.14.5_3.14.5.8-8.1_amd64.deb ...
Unpacking libv8-3.14.5 (3.14.5.8-8.1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_0.10.29~dfsg-2_amd64.deb ...
Unpacking nodejs (0.10.29~dfsg-2) ...
Setting up libc-ares2:amd64 (1.10.0-2+deb8u2) ...
Setting up libv8-3.14.5 (3.14.5.8-8.1) ...
Setting up nodejs (0.10.29~dfsg-2) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.19-18+deb8u10) ...
[91m/bin/sh: 1: npm: not found
With apt-get install nodejs you install only node, but not npm itself. You can check the nodejs files in the debian package index.
To install npm you need to install the npm package.
So, to fix your Dockerfile edit this line:
apt-get install nodejs -y --no-install-recommends;
With:
apt-get install nodejs npm -y --no-install-recommends;

Resources