Install libssl-dev for Docker - docker

I'm building an image for Docker and it's giving me error:
ERROR: unsatisfiable constraints:
libssl-dev (missing):
required by: world[libssl-dev]
running RUN apk add libssl-dev doesn't seem to help.
What can I do to resolve this ?
Dockerfile-dev:
FROM python:3.6.7-alpine
WORKDIR /usr/src/app
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN apk add libssl-dev
RUN apk add libffi-dev
RUN apk add --update python3 python3-dev py-pip build-base
RUN pip3 install -r requirements.txt
COPY . /usr/src/app
CMD python3 manage.py run -h 0.0.0.0

Some packages are built against libressl in Alpine 3.6. Try replacing line 6 in your Dockerfile with the following
RUN apk add libressl-dev

I am just a beginner at apk packages and their dependency conflicts. No guarantees for anything, I just hope it helps someone.
From LibreSSL:
LibreSSL is a version of the TLS/crypto stack forked from OpenSSL in 2014, with goals of modernizing the codebase, improving security, and applying best practice development processes.
Both openssl-dev and libressl-dev depend on libssl. If you install one of the two, you will probably install libssl-dev with it. At least, after running (taken from https://github.com/gliderlabs/docker-alpine/issues/297):
RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev
I got this conflict by running (taken from Installing pandas in docker Alpine, probably not necessary in my case anyway):
RUN apk add postgresql-dev libxml2 libxml2-dev libxslt libxslt-dev libjpeg-turbo-dev zlib-dev
Which outputs:
ERROR: unsatisfiable constraints:
openssl-dev-1.0.2t-r0:
conflicts:
libressl-dev-2.6.5-r0[pc:libcrypto=1.0.2t]
libressl-dev-2.6.5-r0[pc:libssl=1.0.2t]
libressl-dev-2.6.5-r0[pc:openssl=1.0.2t]
satisfies: world[openssl-dev]
libressl-dev-2.6.5-r0:
conflicts:
openssl-dev-1.0.2t-r0[pc:libcrypto=2.6.5]
openssl-dev-1.0.2t-r0[pc:libssl=2.6.5]
openssl-dev-1.0.2t-r0[pc:openssl=2.6.5]
satisfies:
postgresql-dev-10.10-r0[libressl-dev]
We see that the conflict is caused by installing openssl-dev and postgresql-dev.
In this case, it seems that this version of openssl has younger dependencies since the seemingly newer openssl-dev-1.0.2t-r0 (latest version seems to be 1.1.1 in 8/2021, see OpenSSL) conflicts with the older libssl=1.0.2t while the older libressl-dev-2.6.5-r0 (latest version is already 3.4 in 8/2021) conflicts with the younger libssl=2.6.5.
From all this, I read that libssl gets installed as a dependency by openssl-dev or libressl-dev, the latter of which seems to be installed for example by packages like postgresql-dev.

Related

laravel-with-docker-example project fails to build

I am trying to run below project with docker.
https://github.com/kyleferguson/laravel-with-docker-example
which has the below docker file.
FROM php:7-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
&& docker-php-ext-install mcrypt pdo_mysql
WORKDIR /var/www
When i run the "docker-compose up" after running the "composer install".
I get below errors.
executor failed running [/bin/sh -c apt-get update && apt-get install
-y libmcrypt-dev mariadb-client && docker-php-ext-install mcrypt pdo_mysql]: exit code: 1 ERROR: Service 'app' failed to build
Any idea on how to fix this?
Note:
I already tried replacing mariadb-client with mysql-client and default-my-client, still the same issue.
You have a couple problems here, which is why switching to mariadb didn't work on its own.
One way to make it more clear what the problem is, is to bash into a container created from your base image and run the commands manually.
docker run -it php:7-fpm bash
From there if you run each install individually you'll see where you are failing:
# apt-get install -y mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql-client
Either add a repo that provides mysql, or use mariadb.
# docker-php-ext-install mcrypt
error: /usr/src/php/ext/mcrypt does not exist
mcrypt was removed in php 7.2 so you'll need to use pecl to install it, if you really need it.
Unless you're running a very old version of Laravel, you shouldn't need mcrypt.

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

What package should I install instead of libpcre++-dev to use C code in Alpine Golang?

I have a Golang program inside a docker container (I use Ubuntu 18). Also I use github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre for regex in my Golang app. Before using this library I should install libpcre++-dev this way:
sudo apt-get install libpcre++-dev
But I use golang:alpine in my Dockerfile and this is no libpcre++-dev library in alpine packages.
What package should I install instead of libpcre++-dev?
p.s. I have tried to install libc6-compat, pcre pcre-dev, libpcrecpp but I see this error:
github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre
/go/pkg/mod/github.com/glenn-brown/golang-pkg-pcre#v0.0.0-20120522223659-48bb82a8b8ce/src/pkg/pcre/pcre.go:52:10:
fatal error: pcre.h: No such file or directory #include
^~~~~~~~ compilation terminated
My Dockerfile:
FROM golang:alpine
RUN apk update
RUN apk upgrade
RUN apk add --update --no-cache build-base gcc g++ pcre pcre-dev libc6-compat
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache curl git ca-certificates tzdata \
&& update-ca-certificates 2> /dev/null || true
I build my app this way:
- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/backend ./cmd/backend/main.go
EDIT
I have change my Dockerfile (add line below)
RUN apk add --update --no-cache build-base gcc g++ pcre pcre-dev libc6-compat
And now I have a new error:
Error loading shared library libpcre.so.1: No such file or directory
(needed by /bin/backend)
You can try one of these, as both package
RUN apk add --virtual build-dependencies
RUn apk add --no-cache build-base gcc
build-essential is a metapackage (a package that installs many other
packages, like g++ and gcc: the GNU C & C++ compilers).
Or you can install the alpine sdk.
You can start with alpine-sdk, which is a "metapackage that pulls in
the most essential packages used to build new packages."
http://wiki.alpinelinux.org/wiki/Developer_Documentation has more
info.
RUN apk add --update alpine-sdk
docker-alpine-issues-24
Or you can use golang:latest which will work fine.
FROM golang:latest
RUN apt-get update
RUN apt-get install libpcre++-dev -y
You can use one of the Debian-based golang images instead. By the time you're installing GNU libc and a full C toolchain on top of this anyways, there's not really going to be much space savings over the Alpine base image. You can (and should) use a multi-stage build where the final image just contains your compiled binary, and that can use an Alpine base.
The result would look something like:
# Build-time image; just has the parts needed to run `go build`
FROM golang:1.12-buster AS build
# Install additional build-time tools
RUN apt-get update \
&& apt-get install --assume-yes \
build-essential ca-certificates git-core tzdata \
libpcre++-dev
# Build your application
WORKDIR /app
COPY . .
ENV GO111MODULE=on
RUN go build -o myapp ./cmd/myapp
# Runtime image; has only what we need to run the application
FROM alpine:3.10
# Note that you'll need the shared library for libpcre++
RUN apk add ca-certificates tzdata libpcrepp
COPY --from=build /app/myapp /usr/bin/myapp
CMD ["myapp"]

Docker: Alpine linux community package not found

I am trying to create a container with the following Dockerfile:
FROM python:3.6-alpine
RUN apk add --update alpine-sdk make gcc python3-dev python-dev libxslt-dev \
libxml2-dev libc-dev openssl-dev libffi-dev zlib-dev py-pip openssh \
py3-lxml#main py3-numpy#community \
mariadb-dev libjpeg-dev zlib1g-dev && rm -rf /var/cache/apk/*
I added py3-lxml#main and py3-numpy#community based on this advice as building wheel for numpy and lxml takes ages.
I have used the package names as specified on the official Alpine repo page, but I get the following error:
WARNING: The repository tag for world dependency 'py3-lxml#main' does not exist
WARNING: The repository tag for world dependency 'py3-numpy#community' does not exist*
Why is that and how can I get those packages?
In order to fix this problem in specific:
WARNING: The repository tag for world dependency 'py3-lxml#main' does not exist
WARNING: The repository tag for world dependency 'py3-numpy#community' does not exist
You need to update the repositories file which is in here /etc/apk/repositories
to the following unless you want to remove the #community and #main tags from the apk add command as they are not written by default in the repositories file:
#main http://dl-cdn.alpinelinux.org/alpine/v3.9/main
#community http://dl-cdn.alpinelinux.org/alpine/v3.9/community
And don't forget to COPY it the content to /etc/apk/repositories

What library contains cdefs.h on Alpine?

I am trying to compile some code on a Docker image running Alpine. However, gcc keeps terminating due to fatal error: sys/cdefs.h: No such file or directory. People on Google were saying to do
apt install libc6-dev-i386 gcc-multilib
Which I translated to apk add libc6-dev-i386 gcc-multilib. However, then I just get the error. ERROR: unsatisfiable constraints: for both of the libraries.
My Dockerfile is as follows:
FROM alpine
ADD . .
RUN apk update && apk add gcc make openssl libressl-dev musl-dev && make
ENTRYPOINT ./restrictions-crack "$hash" "$salt"
I ended up finding it, the library is bsd-compat-headers
You might use build-base - this is a meta-package that will install the GCC, libc-dev and binutils packages (amongst others).
Dockerfile:
FROM alpine
ADD . .
RUN apk update && apk add build-base && make
ENTRYPOINT ./restrictions-crack "$hash" "$salt"

Resources