Accessing private repositories for Composer using Docker
1 min read

Accessing private repositories for Composer using Docker

Avoiding GitHub Credentials for every time you access your private Composer packages & Repositories

When I run docker-compose run --rm composer update, it always tries to pull in the latest version of my package from Github. Since --rm automatically remove the container when it exits, Composer cannot store the token in /tmp/auth.json

On your docker-compose.yml, include a volume mapping for your /tmp location under volumes:

- ./composer:/tmp

Create a file named auth.json and include this:

{
  "http-basic": {
    "github.com": {
      "username": "",
      "password": ""
    }
  }
}

Make sure you version control it at this point and you can ignore the composer/cache* folders as well. Now insert your username and Personal access token. Running the update statement should no longer ask for your credentials every time.