Apk error unsatisfiable constraints

Hey there! I'm new to docker, and new to alpine in general. I love the work you've done and think it's fantastic for a container-centric future. I'm running into issues using apk up...

Hey there!

I’m new to docker, and new to alpine in general. I love the work you’ve done and think it’s fantastic for a container-centric future. I’m running into issues using apk update and apk add, in addition to apk-install using the base image provided by gliderlabs/docker-alpine:3.1 (and :3.2, for that matter).

Using a Dockerfile that looks like:

FROM gliderlabs/alpine:3.1
RUN apk --update add mysql-client
ENTRYPOINT ["mysql"]

I get this error:

Step 1 : RUN apk --update add mysql-client
 ---> Running in 9129d237031e
fetch http://dl-4.alpinelinux.org/alpine/v3.1/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-4.alpinelinux.org/alpine/v3.1/main: IO ERROR
WARNING: Ignoring APKINDEX.689bb31a.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  mysql-client (missing):
    required by: world[mysql-client]
The command '/bin/sh -c apk --update add mysql-client' returned a non-zero code: 1

After doing some research (which was rather annoying, as the Alpine Linux wiki is down — yay google cache and archive.org), everything I was attempting to do seemed to be correct.

Logically, I figured it was an issue with the repository sources. No problem, let’s open up /etc/apk/repositores.

Whoops! It looks like by default, you only have http://dl-4.alpinelinux.org/alpine/v3.1/main. I ran into #15 and discovered a list of mirrors which have been most helpful. It currently looks like the following sources are currently failing:

http://dl-3.alpinelinux.org/alpine/v3.1/main
http://dl-4.alpinelinux.org/alpine/v3.1/main

1, 2, and 5 are peachy. I propose adding mirrors to the repositories included in your base image. While it’s easy enough for people to add the mirrors themselves, it will save time in the long run, especially for newer users.

Edit (next day): 3 and 4 back up. It would seem the logical choice to add all five mirrors by default.

Cover image for How to Solve: "ERROR: unsatisfiable constraints (python)"

Gustavo Lima

Gustavo Lima

Posted on Jun 3, 2020

• Updated on May 17, 2021

When try to install python2:

apk add --update --no-cache build-base python2-dev python libffi-dev libressl-dev bash git gettext curl

Enter fullscreen mode

Exit fullscreen mode

Get this Error:

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: unsatisfiable constraints:
    python (missing):
      required by: world[python]

Enter fullscreen mode

Exit fullscreen mode

To solve change python2-dev python to python3-dev python3, E.g.:

RUN apk add --update --no-cache build-base python3-dev python3 libffi-dev libressl-dev bash git gettext curl 
 && curl -O https://bootstrap.pypa.io/get-pip.py 
 && python3 get-pip.py 
 && pip install --upgrade six awscli awsebcli

Enter fullscreen mode

Exit fullscreen mode

For Docker containers, Alpine Linux is an optimum choice because of lightweight, low RAM consumption and optimization. However, yet Ubuntu is the best. 

Alpine Linux is a free and open-source Linux operating system for routers, firewalls, VPNs, VoIP computers, servers, virtual machines and containers. It has proactive security features that prevent security holes in the software from being exploited. The small, lightweight Linux distribution based on musl libc and busybox.


I am not going to talk much on Docker here because if you are reading this tutorial then you would already know what it is. Well, in short Docker is a containerized Virtualization platform that allows running different virtual machines in the form of isolated containers. The best thing about it, lightweight and easy to handle; one can simply pull existing Linux or apps images to setup a container from hub.docker.com.

Step 1: Download and Setup Alpine Linux


If you already have a working Alpine Linux then simply move to the next step and if not then go to this link and download one. Alpine Linux is available in multiple forms such as Standard, Extended with some extra packages, Net-install, Optimized Virtual ISO image, for Xen with built-in support for Xen Hypervisor and in Minimal root filesystem for containers. You can download one as per your choice, however, here we are using Alpine Linux Extended version 3.11.

After downloading boot your PC or VirtualBox with it and run the command setup-alpine to follow the installation steps.

Step 2: Command to install Docker on Alpine


Run the following single command to fetch Docker packages for its installation on Alpine.

apk add docker

Install docker on Alpine linux-min

Step 3: Apk add fails with unsatisfiable constraints error 


Incase after executing the above command you get an error “apk add fails with unsatisfiable constraints” then we have to add the following repository to Alpine.

Edit the Alpine repository file:

vi /etc/apk/repositories

Then press Insert button on the keyboard and add the following line in the file.

http://dl-cdn.alpinelinux.org/alpine/latest-stable/community

To save and exit first press Esc and then type:wq after that press the Enter button.

Once you are done, run the package update command to let the system know about the updated repository, so that it can index the same.

apk update

Step 4: Add Docker service to the system boot level


To make sure the service of Docker gets automatically started every time along with the boot of the Alpine, we have to add it to our system services.

rc-update add docker boot

Now, we can start the Docker service

service docker start

Add docker service to boot level-min

Step 5: Install Docker Compose 


Users those also want the Docker Compose on Alpine, first, they have to install pip.

apk add py-pip

Few dev dependencies

apk add python-dev libffi-dev openssl-dev gcc libc-dev make

Finally, run command to install docker-compose

pip install docker-compose

Install Docker compose on ALpine-min

Step 6: Isolate containers with a user namespace


adduser -SDHs /sbin/nologin dockremap
addgroup -S dockremap
echo dockremap:$(cat /etc/passwd|grep dockremap|cut -d: -f3):65536 >> /etc/subuid
echo dockremap:$(cat /etc/passwd|grep dockremap|cut -d: -f4):65536 >> /etc/subgid

Step 7: Now, check your install Docker


Use below command to check information of installed Docker version.

docker info

Step 8 Pull Docker image on Alpine


To know everything is working fine, let’s pull up a hello-world image

docker pull hello-world

To run the image:

docker run -t hello-world

pulling docker image on Alpine

Additional: Errors we encountered while setting it up


1: error response from daemon https //registry-1.docker.io/v2/ time out

We got the above error because in the resolv.conf of Alpine the nameservers were not configured appropriately, thus we edited it:

vi /etc/resolv.conf

And added the following nameservers:

nameserver 8.8.8.8
nameserver 8.8.4.4

2. After installing the Alpine, the network was unreachable, thus we edited:

vi /etc/network/interfaces

And added the following:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

In this way, we can use this lightweight Alpine Linux for Docker running containerized virtual machines.

Error:

ERROR: unsatisfiable constraints:
  libpq-dev (missing):
    required by: world[libpq-dev]
ERROR: Service 'refer-php' failed to build: The command '/bin/sh -c apk update && apk upgrade     && apk add --no-cache --virtual .build-deps ${PHPIZE_DEPS} ${BUILD_DEPENDENSIES}     && apk add --no-cache ${DEPENDENSIES}     && docker-php-ext-install ${EXTENSIONS}     && apk del .build-deps     && rm -rf /tmp/*     && rm -rf /var/cache/apk/*' returned a non-zero code: 1

Dockerfile

FROM php:7.4-fpm-alpine

# Set ENVIRONMENT="production" for production
ARG ENVIRONMENT="development"

ENV DEPENDENSIES="git curl openssh-client icu-dev libxml2-dev libxslt-dev libzip-dev espeak libpq-dev"
ENV BUILD_DEPENDENSIES="g++ make autoconf"
ENV EXTENSIONS="soap intl zip xsl bcmath sockets libpq libpq-dev pdo pdo_pgsql pgsql"
ENV COMPOSER_VERSION="1.8.0"

RUN apk update && apk upgrade 
    && apk add --no-cache --virtual .build-deps ${PHPIZE_DEPS} ${BUILD_DEPENDENSIES} 
    && apk add --no-cache ${DEPENDENSIES} 
    && docker-php-ext-install ${EXTENSIONS} 
    #&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql 
    && apk del .build-deps 
    && rm -rf /tmp/* 
    && rm -rf /var/cache/apk/*

#RUN docker-php-ext-configure pgsql 
#    && docker-php-ext-install pgsql pdo_pgsql

# INSTALL composer
RUN mkdir /etc/composer 
    && wget https://getcomposer.org/installer -P /etc/composer 
    && cd /etc/composer && php ./installer  --filename=composer --verion=${COMPOSER_VERSION} --install-dir=/bin 
    && rm /etc/composer/installer 
    && chmod a+x /bin/composer

# INSTALL xdebug
RUN if [ "$ENVIRONMENT" == "development" ]; then 
    pecl channel-update pecl.php.net 
    && apk add --no-cache --virtual .build-deps ${PHPIZE_DEPS} ${BUILD_DEPENDENSIES} 
    && apk add --no-cache ${DEPENDENSIES} 
    && pecl install xdebug-3.0.1 
    && docker-php-ext-enable xdebug 
    && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 
    && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 
    && echo "xdebug.client_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 
    && echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 
    && echo "xdebug.discover_client_host=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 
    && echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 
    && rm -rf /tmp/* 
    ;fi

COPY init-php.sh /init.sh

ENTRYPOINT ["/init.sh"]

Понравилась статья? Поделить с друзьями:
  • Apk editor studio error packing apk
  • Apk downloader error
  • Apinotactivatedmaperror как исправить
  • Apijob api initialization error no api calls possible inpa ошибка
  • Apierror 10 internal server error