Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide user and pass in curl command in dockerfile

I Have a dockerfile and in one of last steps, I download a WAR file from artifactory, so I can use it in the containers in the webapps/ directory.

Thing is I don´t want to show user and pass of curl -u command. How can I hide both users and password in following command? Is there a way in docker to hide/encrypt passwords?

RUN curl -u user:pass -O "https://artifactory.xxxx.com:443/artifactory/api/api-0.0.1-SNAPSHOT.war"
like image 269
Chanafot Avatar asked Dec 05 '25 02:12

Chanafot


1 Answers

You can use multi stage build to achieve a lightweight image, but you have to use one single docker build, instead of two. Like this single Dockerfile:

FROM maven as build
(... Your app build....)
FROM tomcat
COPY --from=build artifact.war /dest/dir

Everything before the second FROM is discarded from the resulting image, so it will contain Tomcat, not Maven, and your copied artifact.

like image 97
Robert Avatar answered Dec 09 '25 03:12

Robert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!