How to make curl available in Docker image based java:8-jdk-alpine and keep the image clean?

The Java base image you are using is Alpine Linux one and curl package also needs to be downloaded from there. Here is Dockerfile I have used for Production deployments.

FROM openjdk:8-jre-alpine

RUN apk add --update \
    curl \
    && rm -rf /var/cache/apk/*

Update 05/2019

As of Alpine Linux 3.3 there exists a new --no-cache option for apk. It allows users to install packages with an index that is updated and used on-the-fly and not cached locally:

FROM openjdk:8-jre-alpine
    
RUN apk --no-cache add curl

This avoids the need to use --update and remove /var/cache/apk/* when done installing packages.

Reference –
https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md and Thank you @Daniel for the comment.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)