Alpine unsatisfiable constraints: missing packages - docker

I am trying to create a docker image based on alpine:3.7, but I get errors while installing some packages with apk add.
Example:
ERROR: unsatisfiable constraints:
apache2-suexec (missing):
required by: world[apache2-suexec-custom]
host (missing):
required by: world[host]
lpr (missing):
required by: world[lpr]
time (missing):
required by: world[time]
The cause is that these packages do not exist in alpine repositories yet. How can I solve these issues? Is there any repository from which I can download them?
I'm using this line
FROM alpine:3.7
RUN apk update \
&& apk upgrade \
&& apk --no-cache add --update tcl apache2 apache2-suexec ca-certificates \
apk-tools curl build-base supervisor lpr time dcron host rsync libxml2-utils libxslt

You have an issue with the following packages: apache2-suexec, host, lpr and time.
Alpine has some other package structure than main Linux OSs:
apache2-suexec is a part of apache2 package;
host is a part of bind-tools package;
lpr is a part of cups-client package;
time is already in alpine image. It uses busybox's time utility.
So, the final Dockerfile is:
FROM alpine:3.7
RUN apk update \
&& apk upgrade \
&& apk --no-cache add --update tcl apache2 ca-certificates \
apk-tools curl build-base supervisor cups-client dcron bind-tools rsync libxml2-utils libxslt

Related

docker build error on PHPIZE_DEPS in dockerfile

I am trying to build my project from a dockerfile. It suddenly stopped working.
I am trying to use an alpine docker image to put my project and live in it.
FROM renokico/laravel-base:octane-latest-php8.0-alpine
COPY ./extra_files/JSON.php ./vendor/siftscience/sift-php/lib/Services_JSON-1.0.3/
COPY ./extra_files/DBSCAN.php ./vendor/php-ai/php-ml/src/Phpml/Clustering/
COPY ./extra_files/File.php ./vendor/kount/kount-ris-php-sdk/src/Kount/SimpleLogger/
COPY . /var/www/html
RUN apk add --update --no-cache libpq
RUN apk add --no-cache --virtual .build-deps
RUN apk add $PHPIZE_DEPS
RUN apk add postgresql-dev
RUN apk add g++ && \
docker-php-ext-install pdo_pgsql pgsql && \
apk del .build-deps
What could be causing this error below ?
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again
later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/community: temporary error (try
again later)
WARNING: Ignoring APKINDEX.40a3604f.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
dpkg (missing):
required by: world[dpkg]
dpkg-dev (missing):
required by: world[dpkg-dev]
re2c (missing):
required by: world[re2c]
The command '/bin/sh -c apk add $PHPIZE_DEPS' returned a non-zero code: 3

unable to select packages liblzma-dev (no such package), libxml-dev (no such package) in golang:1.14.9-alpine docker

I have try to build docker image using golang:1.14.9-alpine, and i always getting below error for installing thus libraries , what i need to do install thus libraies ?
ERROR: unable to select packages:
liblzma-dev (no such package):
required by: world[liblzma-dev]
libxml-dev (no such package):
required by: world[libxml-dev]
below my docker file
FROM golang:1.14.9-alpine
RUN apk update && apk upgrade \
&& apk --no-cache --update add build-base
RUN apk add --no-cache \
alpine-sdk \
protobuf \
ca-certificates \
curl \
make \
libx11-dev \
libxslt-dev \
libxml2 \
gcc \
g++ \
ca-certificates \
libxml-dev \
liblzma-dev \
libxslt-dev
RUN go get github.com/golang/protobuf/proto#v1.4.3
RUN go get github.com/golang/protobuf/protoc-gen-go#v1.4.3
RUN go get github.com/micro/protoc-gen-micro/v2
RUN export GO111MODULE=on
COPY . .
RUN make build
RUN chmod 765 test-service
I think the package is xz-dev
You can try a multistage build and then copy the required executables to alpine version. It will optimize the build further.
You can try something like this:
# Build Stage
FROM golang:1.14.9 as build
...
# Build here
RUN make build
...
# Release stage
FROM alpine:3.13.5 as release
# Copy only the needed files
COPY --from=build <build output> <exec location>
CMD <exec>

Alpine ERROR: unsatisfiable constraints: py3-pandas (missing):

I have the following dockerfile:
FROM alpine:latest
ADD crontab.txt /crontab.txt
ADD script.sh /script.sh
COPY entry.sh /entry.sh
ADD app /app
RUN chmod 755 /script.sh /entry.sh
RUN /usr/bin/crontab /crontab.txt
# install dependencies
# the lapack package is only in the community repository
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache python3 py-pip py3-setuptools python-dev py3-lxml py3-requests py3-numpy py3-cssselect py3-pandas
RUN apk --update add --no-cache \
lapack-dev \
gcc \
freetype-dev
# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
gfortran \
musl-dev \
g++
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
#RUN pip3 install cython
RUN pip3 install pymongo xlrd
CMD ["/entry.sh"]
when I try to build the dockerfile, I received the error saying that py3-pandas (missing).
I am wondering whether that's the Alpine package management issue.
I can reproduce your issue by doing just:
FROM alpine:latest
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache py3-pandas
Some comments here:
If you are going to use the edge/testing packages repository already, then you would be better using the alpine:edge image, although I would not advise this for a production server, of course
Using another package repository than the default one on apk can be done on a one run basis using the option
-X, --repository REPO Use packages from REPO
From apk --help
The package python-dev does not exist in the edge/testing repository, you should use python3-dev
Important disclaimer: this solution does involve using the testing repository and the edge rolling release branch of Alpine, and is thus not recommended for production use.
So, in the end, all your dependencies can be installed doing:
FROM alpine:edge
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
py-pip \
py3-setuptools \
python3-dev \
py3-lxml \
py3-requests \
py3-numpy \
py3-cssselect \
py3-pandas \
lapack-dev \
gcc \
freetype-dev
Note that I didn't add the build dependancies there, as they don't seems to be related to your issue at hand
Don't use alpine images for python; there's too many issues. Use a something like python:slim-buster. You can then just install your requirements with:
FROM python:3.8.4-slim-buster
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

Alpine package py3-scipy is missing

I'm in an alpine linux docker container, and I'm trying to install py3-scipy. Here is info on that package: https://pkgs.alpinelinux.org/package/edge/community/x86/py3-scipy. I want to do this because pip install scipy takes way too long.
Here is what I get:
/ # apk add py3-scipy
ERROR: unsatisfiable constraints:
py3-scipy (missing):
required by: world[py3-scipy]
My Dockerfile:
FROM alpine:3.9
RUN apk add --update python3-dev g++ gcc libxslt-dev cython lapack-dev gfortran build-base py3-scipy
What is causing this error?
I think this issue sometimes happen when alpine moves a package from edge/testing to edge/community so old versions of alpine will keep referring to the old url. So you need to try to use the latest alpine version alpine:latest instead of a specific version.
I was missing the echo step, with that I was able to install it:
echo "#testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
apk add --update --no-cache py3-scipy

ERROR: unsatisfiable constraints - on php:7-fpm-alpine

I'm looking at setting up laravel on an fpm-alpine container. Running into a snag where the below Dockerfile is producing some errors...
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk --update add \
php7-mysqli \
php7-mcrypt \
php7-mbstring \
rm /var/cache/apk/*
Errors produced are:
Building fpm
Step 1 : FROM php:7-fpm-alpine
---> 9e6811cb8bac
Step 2 : RUN apk --update add php7-mysqli php7-mcrypt php7-mbstring rm /var/cache/apk/*
---> Running in 87364957eb57
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
/var/cache/apk/* (missing):
required by: world[/var/cache/apk/*]
php7-mbstring (missing):
required by: world[php7-mbstring]
php7-mcrypt (missing):
required by: world[php7-mcrypt]
php7-mysqli (missing):
required by: world[php7-mysqli]
rm (missing):
required by: world[rm]
ERROR: Service 'fpm' failed to build: The command '/bin/sh -c apk --update add php7-mysqli php7-mcrypt php7-mbstring rm /var/cache/apk/*' returned a non-zero code: 5
I can search for these package names and find them on the alpine linux web site. Any thoughts on how I can work around this? It's like it's not updating the apt cache... but adding an LS I can see contents there:
Building fpm
Step 1 : FROM php:7-fpm-alpine
---> 9e6811cb8bac
Step 2 : RUN apk update
---> Using cache
---> 9ef09f3aa2a2
Step 3 : RUN ls /var/cache/apk
---> Running in e126a083a306
APKINDEX.5a59b88b.tar.gz
APKINDEX.7c1f02d6.tar.gz
Any ideas on what I can do to resolve this?
Base Docker image probably references an incorrect repository.
Pass over the correct repositories to the apk add command like this:
RUN apk add --update \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
php7-mysqli php7-mcrypt php7-mbstring
I wasn't using docker-php-ext-install which is required when adding working within the container...
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk update \
&& apk add libmcrypt-dev \
&& docker-php-ext-install mcrypt mysqli pdo_mysql \
&& rm /var/cache/apk/*
I met the same error. Solved it by removing the package version from its name:
https://github.com/docker-library/php/issues/225#issuecomment-220339154
I met the same error, and tried the solution here, found the apk update is crucial.

Resources