I want to download a file from the Jenkins server that requires authentication(username and password) using Dockerfile
below provided is the first two lines of my Dockerfile
FROM eclipse-temurin:17-alpine
RUN apk update && apk add --no-cache gcompat
and then I have
ENV REPO_USERNAME=test
ENV REPO_PASSWORD=testPassword
the eclipse-temurin:17-alpine contains wget, so I assume I do not need to install it additionally , so I imagine the solution will look like
RUN wget --user="$REPO_USERNAME" --password="$REPO_PASSWORD" -O reqLoader-linux http://10.80․10․2/tools/puppeteer-v13/reqLoader-linux
but when running the Dockerfile I am getting this error message
#14 [10/14] RUN wget --user="test" --password="testPassword" -O reqLoader-linux http://10.80.10.2/tools/puppeteer-v13/reqLoader-linux
#14 0.272 wget: unrecognized option: password=testPassword
#14 0.275 BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.
#14 0.275
#14 0.275 Usage: wget [-cqS] [--spider] [-O FILE] [-o LOGFILE] [--header STR]
#14 0.275 [--post-data STR | --post-file FILE] [-Y on/off]
#14 0.275 [-P DIR] [-U AGENT] [-T SEC] URL...
#14 0.275
#14 0.275 Retrieve files via HTTP or FTP
#14 0.275
#14 0.275 --spider Only check URL existence: $? is 0 if exists
#14 0.275 --header STR Add STR (of form 'header: value') to headers
#14 0.275 --post-data STR Send STR using POST method
#14 0.275 --post-file FILE Send FILE using POST method
#14 0.275 -c Continue retrieval of aborted transfer
#14 0.275 -q Quiet
#14 0.275 -P DIR Save to DIR (default .)
#14 0.275 -S Show server response
#14 0.275 -T SEC Network read timeout is SEC seconds
#14 0.275 -O FILE Save to FILE ('-' for stdout)
#14 0.275 -o LOGFILE Log messages to FILE
#14 0.275 -U STR Use STR for User-Agent header
#14 0.275 -Y on/off Use proxy
#14 ERROR: process "/bin/sh -c wget --user=\"$REPO_USERNAME\" --password=\"$REPO_PASSWORD\" -O reqLoader-linux http://10.80․10․2/tools/puppeteer-v13/reqLoader-linux" did not complete successfully: exit code: 1
------
> [10/14] RUN wget --user="test" --password="testPassword" -O reqLoader-linux http://10.80․10․2/tools/puppeteer-v13/reqLoader-linux:
0.275 --post-file FILE Send FILE using POST method
0.275 -c Continue retrieval of aborted transfer
0.275 -q Quiet
0.275 -P DIR Save to DIR (default .)
0.275 -S Show server response
0.275 -T SEC Network read timeout is SEC seconds
0.275 -O FILE Save to FILE ('-' for stdout)
0.275 -o LOGFILE Log messages to FILE
0.275 -U STR Use STR for User-Agent header
0.275 -Y on/off Use proxy
------
Dockerfile:18
--------------------
16 |
17 | # Download reqLoader-linux and move it to the puppeteer directory
18 | >>> RUN wget --user="$REPO_USERNAME" --password="$REPO_PASSWORD" -O reqLoader-linux http://10.80․10․2/tools/puppeteer-v13/reqLoader-linux
I see that the problem comes from providing the username and password in the command because there is no that kind of parameter
Detail - I am running Dockerfile using .sh file in git bash(windows 11)
Any other suggestion on how to download files using Dockerfile from remote server that requires authentication is very much appreciated
The purpose of this is to have those files in the image.
The error is because you are using wget, but Alpine Linux doesn’t support “—user” and “—password” directly. So try using curl, which would look like this:
FROM eclipse-temurin:17-alpine
RUN apk update && apk add --no-cache curl
ENV REPO_USERNAME=test
ENV REPO_PASSWORD=testPassword
RUN curl --user "$REPO_USERNAME:$REPO_PASSWORD" -o reqLoader-linux http://10.80.10.2/tools/puppeteer-v13/reqLoader-linux