Beno Odr
Beno Odr

Reputation: 1273

Use latest curl version on docker

I've the following docker image

FROM debian:10.7

RUN apt-get update && \
    apt-get install --yes --no-install-recommends curl

when I run it and use curl --version I got version 7.64 but the latest is 7.74 https://curl.haxx.se/download.html

How should I upgrade the curl to the latest version 7.74 ?
is there a way to do it?

Upvotes: 6

Views: 12478

Answers (4)

CaMiX
CaMiX

Reputation: 750

The accepted answer didn't work for me. I ran into several issues with SSL and libs. The following changes I made fixes all of the issues I ran into:

RUN apt-get update && \ 
    apt-get install -y wget build-essential libssl-dev && \
    wget https://curl.se/download/curl-8.1.2.tar.gz && \
    tar -xvf curl-8.1.2.tar.gz && \ 
    cd curl-8.1.2 && \ 
    ./configure --with-ssl && \
    make && \
    make install && \
    ln -s /usr/local/bin/curl /usr/bin/curl && \
    ldconfig

Upvotes: 3

Luiz Ferreira
Luiz Ferreira

Reputation: 66

You can use the downloaded packages directly to solve this problem by installing with the make command.

FROM debian:10.7

RUN apt-get update && \
    apt-get install --yes --no-install-recommends wget build-essential libcurl4 && \
    wget https://curl.se/download/curl-7.74.0.tar.gz && \
    tar -xvf curl-7.74.0.tar.gz && cd curl-7.74.0 && \
    ./configure && make && make install

Note that it requires running ./configure.

After installation curl will work perfectly in the version you need, in this case, version 7.74.0.

If you want to optimize your container, remove the build-essential package, it alone will consume more than 200MB of storage. To do this, add at the end of the compilation:

apt-get autoremove build-essential

Upvotes: 4

Raman Sailopal
Raman Sailopal

Reputation: 12877

The latest version of Curl on Alpine Linux is available from the following link:

https://github.com/curl/curl-docker/blob/master/alpine/latest/Dockerfile

Upvotes: 0

Arkadiusz Drabczyk
Arkadiusz Drabczyk

Reputation: 12403

You could clone curl source code from Git and build and install it manually in your Dockerfile like that:

FROM debian:10.7

RUN apt-get update && \
    apt-get install --yes --no-install-recommends autoconf libtool automake make git

RUN GIT_SSL_NO_VERIFY=1 git clone https://github.com/curl/curl --depth 1
RUN cd curl && ./buildconf && ./configure && make -j$(nproc) install && \
    echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf && ldconfig

After docker run:

root@d7ea28ad22e2:/# curl --version
curl 7.75.0-DEV (x86_64-pc-linux-gnu) libcurl/7.75.0-DEV
Release-Date: [unreleased]
Protocols: dict file ftp gopher http imap mqtt pop3 rtsp smtp telnet tftp
Features: alt-svc AsynchDNS IPv6 Largefile UnixSockets

Upvotes: 1

Related Questions