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.
Related
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
This is my simple Dockerfile. The issue is SCALA_VERSION variable in the line wget -q --no-cookies ... does not get interpolated. I am not sure how to fix that. I appreciate any help or hint.
ARG SCALA_MAJOR_VERSION="2.13"
ARG SCALA_MINOR_VERSION="7"
ARG SCALA_VERSION="$SCALA_MAJOR_VERSION.$SCALA_MINOR_VERSION"
FROM openjdk:18-jdk-alpine AS base
LABEL version="$SCALA_VERSION"
WORKDIR /usr/lib
RUN apk add --no-cache bash \
&& apk add --no-cache --virtual=build-dependencies wget ca-certificates \
&& wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x \
&& apk del build-dependencies \
&& rm -rf /tmp/*
Logs:
➜ compiler-toolchain git:(master) ✗ docker build . -t cool
Sending build context to Docker daemon 16.54MB
Step 1/18 : ARG SCALA_MAJOR_VERSION="2.13"
Step 2/18 : ARG SCALA_MINOR_VERSION="7"
Step 3/18 : ARG SCALA_VERSION="$SCALA_MAJOR_VERSION.$SCALA_MINOR_VERSION"
Step 4/18 : FROM openjdk:18-jdk-alpine AS base
---> c89120dcca4c
Step 5/18 : LABEL maintainer="boyland#uwm.edu"
---> Using cache
---> eb84f71065ca
Step 6/18 : LABEL version="$SCALA_VERSION"
---> Using cache
---> 23f11d22b6cb
Step 7/18 : WORKDIR /usr/lib
---> Using cache
---> 8762269e3700
Step 8/18 : RUN apk add --no-cache bash && apk add --no-cache --virtual=build-dependencies wget ca-certificates && wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x && apk del build-dependencies && rm -rf /tmp/*
---> Running in 0cc02cf39a42
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.3_p20211120-r0)
(2/4) Installing ncurses-libs (6.3_p20211120-r0)
(3/4) Installing readline (8.1.1-r0)
(4/4) Installing bash (5.1.8-r0)
Executing bash-5.1.8-r0.post-install
Executing busybox-1.34.1-r3.trigger
OK: 10 MiB in 24 packages
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/4) Installing libunistring (0.9.10-r1)
(2/4) Installing libidn2 (2.3.2-r0)
(3/4) Installing wget (1.21.2-r2)
(4/4) Installing build-dependencies (20211220.220536)
Executing busybox-1.34.1-r3.trigger
OK: 13 MiB in 28 packages
gunzip: invalid magic
tar: short read
The command '/bin/sh -c apk add --no-cache bash && apk add --no-cache --virtual=build-dependencies wget ca-certificates && wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x && apk del build-dependencies && rm -rf /tmp/*' returned a non-zero code: 1
It's FROM openjdk:18-jdk-alpine AS base that does it. The ARGs set before you base on the new image aren't carried over. You need to move the ARG statements to after the FROM like this
FROM openjdk:18-jdk-alpine AS base
ARG SCALA_MAJOR_VERSION="2.13"
ARG SCALA_MINOR_VERSION="7"
ARG SCALA_VERSION="$SCALA_MAJOR_VERSION.$SCALA_MINOR_VERSION"
LABEL version="$SCALA_VERSION"
WORKDIR /usr/lib
RUN apk add --no-cache bash \
&& apk add --no-cache --virtual=build-dependencies wget ca-certificates \
&& wget -q --no-cookies "https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" -O - | gunzip | tar x \
&& apk del build-dependencies \
&& rm -rf /tmp/*
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>
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
I'm trying to install postgis into a postgres container.
Dockerfile:
FROM postgres:9.6.4-alpine
RUN apk update \
&& apk add -u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts \
&& rm -rf /var/lib/apt/lists/*
COPY ./scripts/postgis.sh /docker-entrypoint-initdb.d/postgis.sh
postgis.sh:
#!/bin/sh
for DB in $(psql -t -c "SELECT datname from pg_database where datname = 'backend'"); do
echo "Loading PostGIS extensions into $DB"
"${psql[#]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
EOSQL
done
I got this error:
ERROR: unsatisfiable constraints:
postgresql-9.6-postgis-2.4 (missing):
required by:
world[postgresql-9.6-postgis-2.4]
postgresql-9.6-postgis-2.4-scripts (missing):
required by:
world[postgresql-9.6-postgis-2.4-scripts]
The command '/bin/sh -c apk update && apk add -u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 2
I found similar questions such as :
ERROR: unsatisfiable constraints: while installing package in alpine
ERROR: unsatisfiable constraints - on php:7-fpm-alpine
But it doesn't solve my problem.How can I add postgis extension to my postgres container with apk?
Postgis package is only available in edge alpine repo, not in a stable one. That's why you are getting "unsatisfiable constraints" error.
But anyway you can install postgis from edge repo:
# echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
# apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
v3.5.2-254-g9d4623dc57 [http://dl-cdn.alpinelinux.org/alpine/v3.5/main]
v3.5.2-247-gc85efb30e1 [http://dl-cdn.alpinelinux.org/alpine/v3.5/community]
v3.7.0-2163-ge03552fc58 [http://dl-cdn.alpinelinux.org/alpine/edge/testing]
OK: 10930 distinct packages available
# apk search --no-cache postgis
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
postgis-dev-2.4.1-r1
postgis-2.4.1-r1
postgis-doc-2.4.1-r1
So, the final Dockerfile is:
FROM postgres:9.6.4-alpine
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update \
&& apk add -u postgis \
&& rm -rf /var/lib/apt/lists/*
COPY ./scripts/postgis.sh /docker-entrypoint-initdb.d/postgis.sh
UPDATED on January 23th 2020:
Postgis is available in main and community repositories starting from Alpine version 3.11:
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ #
/ # apk search --no-cache postgis
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
postgis-3.0.0-r1
postgis-doc-3.0.0-r1
You don't need to use edge repo testing branch for Alpine version 3.11 and later.
Old:
apk add --no-cache curl jq python py-pip
New:
apk add --no-cache curl jq python3 py3-pip
It is weird but in my case solution was as simple as to run:
sudo systemctl restart docker
... on a machine where you running docker containers