Docker Alpine linux package masked - linux

I am trying to install a package on my docker image that runs alpine but I get the following error,
Removing intermediate container 54bbe0932899
Step 14 : RUN apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
---> Running in 24d7a8c00c89
fetch http://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
openblas-0.2.19-r0:
masked in: #community
satisfies: world[openblas]
openblas-dev-0.2.19-r0[openblas=0.2.19-r0]
openblas-ilp64-0.2.19-r0:
masked in: #community
satisfies:
openblas-dev-0.2.19-r0[openblas-ilp64=0.2.19-r0]
openblas-dev-0.2.19-r0:
masked in: #community
satisfies: world[openblas-dev]
ERROR: Service 'web' failed to build: The command '/bin/sh -c apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted' returned a non-zero code: 3
Important part of the Dockerfile:
FROM python:3.5.2-alpine
ADD repositories /etc/apk/repositories
RUN apk upgrade --update
RUN apk add --update libstdc++ curl ca-certificates bash
RUN apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
RUN apk add --update py-scipy py-numpy py-numpy-dev
The repository file is
http://dl-cdn.alpinelinux.org/alpine/v3.4/main
#testing http://dl-cdn.alpinelinux.org/alpine/edge/testing
#community http://dl-cdn.alpinelinux.org/alpine/edge/community
How I can force the installation of openblas?
I am new to alpine so apologies if this is a straight forward question.

I found the solution,
the following line:
RUN apk add openblas openblas-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
should be
RUN apk add openblas#community openblas-dev#community --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ --allow-untrusted
Now docker continues to the next stage.

Related

alpine linux apk installation error in Dockerfile

I am trying to execute the following code in a Dockerfile:
FROM alpine:3.7
RUN apk update && apk add --no-cache busybox musl prometheus-node-exporter
RUN rc-update add prometheus-node-exporter default
RUN rc-service prometheus-node-exporter start
RUN echo " - job_name: node \
# If prometheus-node-exporter is installed, grab stats about the local \
# machine by default. \
static_configs: \
- targets: ['localhost:9100', 'alpine_distro:9100']" >> /etc/prometheus/prometheus.yml
but my build returns the following error:
ERROR:
unsatisfiable constraints:
prometheus-node-exporter (missing):
required by: world[prometheus-node-exporter]
The command '/bin/sh -c apk update && apk add --no-cache busybox musl prometheus-node-exporter' returned a non-zero code: 1
I am not used to Alpine package manager but my guess is that I might not be using a repo that contains prometheus-node-exporter?
Or am I missing something else?
If from some reason you're forced to use Alpine 3.7, you could install the prometheus-node-exporter package from the Alpine 3.13 community repo:
$ sudo docker run -it alpine:3.7
/ # apk add prometheus-node-exporter --repository=http://dl-cdn.alpinelinux.org/alpine/v3.13/community
fetch http://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/1) Installing prometheus-node-exporter (1.0.1-r0)
Executing prometheus-node-exporter-1.0.1-r0.pre-install
24% ###################################
Executing busybox-1.27.2-r11.trigger
OK: 20 MiB in 14 packages
/ #
/ #
/ # node_exporter --help
usage: node_exporter [<flags>]
...
It seems node_exporter only depends on musl, so it's likely to work well without special issues:
/ # ldd /usr/bin/node_exporter
/lib/ld-musl-x86_64.so.1 (0x7fea4c68a000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fea4c68a000)
However, if you have that option, it's recommended to upgrade your base Alpine version to 3.13, instead.

internet connection issue while creating Docker Image

I am trying to create a simple docker image in AWS EC2.
I have the following Dockerfile.
FROM node:12-alpine
RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
RUN mkdir -p /home/project/website/node_modules && chown -R node:node /home/project/website
WORKDIR /home/project/website
COPY /package*.json ./
USER node
RUN npm cache verify
RUN npm install
COPY --chown=node:node . .
RUN chmod +x wait-for.sh
RUN chmod -R 0755 /home/project/website/src/views/
EXPOSE 8000
when I try to build by this following command
docker-compose build
I got the following output
Step 2/12 : RUN apk add --no-cache build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
---> Running in 208f43729d68
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
autoconf (missing):
required by: world[autoconf]
automake (missing):
required by: world[automake]
build-base (missing):
required by: world[build-base]
gcc (missing):
required by: world[gcc]
libpng-dev (missing):
required by: world[libpng-dev]
libtool (missing):
required by: world[libtool]
nasm (missing):
required by: world[nasm]
zlib-dev (missing):
required by: world[zlib-dev]
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
ERROR: unsatisfiable constraints:
and I have already created it for the first time and everything was running successful, but I have changed some paths on my docker file and I have removed all containers, images, volumes...
but this time I got this error.
I solved the problem by the following commands
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d
Here is the original answer
My docker container has no internet

Docker python3.8 alpine python-ldab installation fails missing lber.h

I am trying to pip install python-ldap in Docker but am missing lber.h. I need python-ldap because I am trying to implement an OS agnostic SSO for my application, following this for now and hoping it doesn't break the rest of my app https://code.tutsplus.com/tutorials/flask-authentication-with-ldap--cms-23101
I have tried
RUN apk add libsasl2-dev libldap2-dev libssl-dev
and
RUN apk --no-cache add libsasl2-dev libldap2-dev libssl-dev
but I get the following error:
ERROR: unsatisfiable constraints:
libldap2-dev (missing):
required by: world[libldap2-dev]
libsasl2-dev (missing):
required by: world[libsasl2-dev]
libssl-dev (missing):
required by: world[libssl-dev]
Having gone to https://pkgs.alpinelinux.org/packages?name=libldap2-dev&branch=edge I feel that it is possible that these packages do indeed not exist within the alpine python image. Therefore, I tried substituting the installations with packages that exist in the above link, namely: openssl libsasl libldap
This didn't work either and had the same effect as not installing any of the packages i.e. the header missing error appeared:
Modules/constants.h:7:10: fatal error: lber.h: No such file or directory
#include "lber.h"
^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
as a result of /tmp/pip-install-doifa8k9/python-ldap/
My Dockerfile:
FROM python:3.8.0-alpine
WORKDIR /home/flask
ADD . /home/flask
RUN apk --no-cache add --update --virtual .build-editdistance gcc g++ && \
apk --no-cache add libsasl libldap openssl && \
apk --no-cache add --update --virtual .libs libstdc++ && \
apk add linux-headers && \
apk add unixodbc-dev;
RUN rm -rf /var/cache/apk/* && \
pip install --upgrade pip && \
pip install --upgrade setuptools && \
pip install --no-cache-dir -Ur requirements.txt && \
apk del .build-editdistance;
EXPOSE 5000
For alpine python in docker:
apk add openldap-dev
instead of
apk add libsasl libldap openssl
This is answered in I can't install python-ldap but the answer is buried sufficiently deep and obfuscated by the accepted answer ( which is where libsasl libldap openssl came from) that it would be a good idea to keep this docker specific question

How to install libvips on Alpine 3.8?

I try to install vips-dev package to alpine linux 3.8. But get following error:
docker run -it --rm alpine:3.8 /bin/sh -c "apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing vips-dev"
fetch http://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
pc:fftw3 (missing):
required by: vips-dev-8.7.4-r1[pc:fftw3] vips-dev-8.7.4-r1[pc:fftw3] vips-dev-8.7.4-r1[pc:fftw3]
How to solve it?
This is a known packaging issue of vips-dev on edge/testing:
https://bugs.alpinelinux.org/issues/9561
As a workaround, make sure to add both edge/main and edge/testing repositories to your apk command:
sudo docker run -it --rm alpine:3.8 /bin/sh -c "apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing --repository http://dl-3.alpinelinux.org/alpine/edge/main vips-dev"
Update, 30/5/19:
vips-dev has moved from the edge/testing branch to edge/community, and updated to version 8.8.0-r0. Therefore, the updated command line is:
sudo docker run -it --rm alpine:3.8 /bin/sh -c "apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community --repository http://dl-3.alpinelinux.org/alpine/edge/main vips-dev"

ERROR: unsatisfiable constraints: nodejs-npm (missing)

I'm trying to install nodeJs, npm and newman in my docker image, so I have this in the docker file :
FROM python:3.6.1-alpine
RUN apk update && \
apk add --no-cache nodejs-npm && \
apk add --update nodejs && \
npm install newman --global
That gives me this error:
ERROR: unsatisfiable constraints:
nodejs-npm (missing):
required by: world[nodejs-npm]
I got the command from this question: How to install npm in alpine linux
How can I fix this?
Docker image python:3.6.1-alpine is based on Alpine Linux v3.4.
According to alpine packages portal, npm binary can be found in nodejs package in Alpine Linux version 3.4.
So, the final Dockerfile is:
FROM python:3.6.1-alpine
RUN apk update && \
apk add --update nodejs && \
npm install newman --global

Resources