Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fkurz/fc4e0b689c68ee771b39d5131010fa36 to your computer and use it in GitHub Desktop.
Save fkurz/fc4e0b689c68ee771b39d5131010fa36 to your computer and use it in GitHub Desktop.
Troubleshooting: Retrieving Private Repositories in Docker Build Phase

Retrieving Private Repositories in Docker Build Phase

Problem

During the build phase you may need to access dependencies in private (or, generally non-public) repositories.

Solution

This solution configures Git to use HTTPS with login and access token for the repository with URL <repo-url>.

  1. Create an access token (see 1)
  2. Add the following lines to your Dockerfile
    ARG LOGIN
    ARG TOKEN
    # Configure Git to use HTTPS with access token for git.maibornwolff.de; retrieve dependencies
    RUN git config --global url."https://${LOGIN}:${TOKEN}@<repo-url>/".insteadOf "https://<repo-url>/" 
  3. Run docker build with arguments --build-arg <login> --build-arg <token>
     docker build -t <tag> --build-arg <login> --build-arg <token> <dockerfile>

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment