Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

Using access tokens on Dockerfile to clone repository: RUN command error

$
0
0

In a Dockerfile, I'm trying to clone several Gitlab repositories that are specified in a file, one per line, using an access token passed as an environment variable set in docker-compose.yml:

COPY my-repos.txt my-repos.txtRUN 'cat my-repos.txt | while read REPO; do git clone https://oauth2:$GITLAB_ACCESS_TOKEN@gitlab2.<domain>.com:16443/$REPO.git; done'

But I'm getting the following error:

/bin/sh: 1: cat my-repos.txt | while read REPO; do git clone https://oauth2:$GITLAB_ACCESS_TOKEN@gitlab2.<domain>.com:16443/$REPO.git; done: not foundThe command '/bin/sh -c 'cat my-repos.txt | while read REPO; do git clone https://oauth2:$GITLAB_ACCESS_TOKEN@gitlab2.<domain>.com:16443/$REPO.git; done'' returned a non-zero code: 127

Running without quotes gives another error:

Cloning into 'ML_tools'...remote: HTTP Basic: Access deniedfatal: Authentication failed for 'https://gitlab2.<domain>.com:16443/<correct_repo>.git/'The command '/bin/sh -c cat my-repos.txt | while read REPO; do git clone https://oauth2:$GITLAB_ACCESS_TOKEN@gitlab2.<domain>.com:16443/$REPO.git; done' returned a non-zero code: 128

The thing is, if I comment out the RUN line, build the image and enter the container, running manually the command works perfectly. The environment variable is correctly set. Is maybe some variable out of scope at build time?


Viewing all articles
Browse latest Browse all 136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>