skip to Main Content

Dockerfile for my NodeJS application looks like the following

FROM node:14-alpine AS build

# Install necessary packages using the 'apk' package manager
RUN apk update && 
    apk add --no-cache wget build-base openssl-dev

# Install a more recent version of curl
RUN apk add --no-cache curl

# Set the source folder
ARG SOURCE_FOLDER="./"
ARG BUILD_VERSION
ARG NPM_TOKEN

# Create app directory
WORKDIR /var/www/app

# Bundle app source
COPY ${SOURCE_FOLDER} .

# Run the build.sh script
RUN chmod +x build.sh && ./build.sh


RUN NODE_OPTIONS=--max_old_space_size=4096 lsc build site --output-hashing all --buildVersion=$BUILD_VERSION && 
    rm -f .npmrc

FROM app-base/docker-base

COPY --from=build /var/www/app/dist/ngx-rsc-app /var/www/app

I am trying to install latest version of curl and libcurl using the command

RUN apk add --no-cache curl

But when I go into my container and check the curl version

root@my-app:/var/www/app# curl --version
curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

It shows curl 7.74.0 instead of curl 8.4.0. How should I upgrade the curl and libcurl to the latest version 8.4.0 ?

2

Answers


  1. You’re using a multistage Dockerfile and installing curl in the first stage. That install doesn’t carry over to the final stage.

    There are (at least) 2 ways to update curl in the final image

    • you can update curl in the app-base/docker-base image. That will
      update curl for all users of the base image.
    • you can install curl
      8.4.0 in the final stage of your Dockerfile. How to do that depends on what package manager is available in the app-base/docker-base
      image.
    Login or Signup to reply.
  2. To upgrade curl and libcurl to the latest version in your Dockerfile, there are a few options:

    1. Update in the base image

    As mentioned, you can update curl and libcurl in the app-base/docker-base image that you’re using as your final stage. This has the benefit of upgrading all images that use that base, but requires updating the base image.

    1. Install in the final stage

    You can install the latest curl and libcurl in the final stage of your Dockerfile. This will only upgrade that specific image.

    Since you’re using Alpine Linux, you can run:

    RUN apk update 
        && apk add curl libcurl
    

    This will install the latest available versions from the Alpine repos.

    1. Pull from curl’s Docker image

    You can pull directly from the official curl Docker image to get the latest version:

    FROM curl:latest
    
    # Rest of Dockerfile...
    

    This ensures you always have the absolute latest curl and libcurl.

    1. Install from source

    As a last resort, you can install curl and libcurl from source to get a specific version. This is more complex but gives you full control.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search