DEV Community

adithyasrinivasan
adithyasrinivasan

Posted on • Originally published at adithya.dev on

Accessing private repositories for Composer using Docker

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": ""
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)