fuzes
fuzes

Reputation: 2057

I can't install specific version (1.0.2g) of openssl in docker

I want to install openssl version 1.0.2g in docker image so I wrote Dockerfile:

RUN apt-get update
RUN apt-get install -y build-essential cmake zlib1g-dev libcppunit-dev git subversion && rm -rf /var/lib/apt/lists/*
RUN wget https://www.openssl.org/source/openssl-1.0.2g.tar.gz -O - | tar -xz
WORKDIR /openssl_1.0.2g
RUN ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

and tried to build it:

Removing intermediate container 0666b2c5021f
 ---> e92f7ed1e3a0
Step 11/14 : WORKDIR /openssl_1.0.2g
Removing intermediate container c8e083d9a453
 ---> 112f18273e8f
Step 12/14 : RUN ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
 ---> Running in 4871c00e5c35
/bin/sh: 1: ./config: not found
The command '/bin/sh -c ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl' returned  a non-zero code: 127

but it doesn't work...

How can I fix it?

Upvotes: 7

Views: 18204

Answers (2)

toing_toing
toing_toing

Reputation: 2442

To install recent versions of OPENSSL (version 3+) on docker, the following works (tested on ubuntu 20.04 and debian 10:

RUN apt-get update &&\
    apt-get -y remove openssl &&\
    apt-get -y install build-essential zlib1g-dev &&\
    apt-get -q update && apt-get -qy install wget make &&\
    wget https://www.openssl.org/source/openssl-3.0.5.tar.gz &&\
    tar -xzvf openssl-3.0.5.tar.gz &&\
    cd openssl-3.0.5 &&\
    ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib &&\
    make &&\
    make install

RUN cat <<'EOT' | tee /etc/ld.so.conf.d/openssl-3.0.5.conf
/usr/local/ssl/lib64
EOT


RUN ldconfig -v &&\
    mv /usr/bin/openssl /usr/bin/openssl.bak &&\
    mv /usr/bin/c_rehash /usr/bin/c_rehash.bak &&\
    update-alternatives --install /usr/bin/openssl openssl /usr/local/ssl/bin/openssl 1 &&\
    update-alternatives --install /usr/bin/c_rehash c_rehash /usr/local/ssl/bin/c_rehash 1

Upvotes: 1

nickgryg
nickgryg

Reputation: 28593

What base image do you use to build an image?

It works pretty fine with ubuntu:16.04 base image and the same Dockerfile you provided:

FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y build-essential cmake zlib1g-dev libcppunit-dev git subversion wget && rm -rf /var/lib/apt/lists/*

RUN wget https://www.openssl.org/source/openssl-1.0.2g.tar.gz -O - | tar -xz
WORKDIR /openssl-1.0.2g
RUN ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl && make && make install

Upvotes: 8

Related Questions