Using Multiple Docker Repositories

Sunday, March 4, 2018

Depending on the project I work in a multitude of different Docker repositories across multiple services. This includes using Google, Amazon, and Docker hub. Logging into each one of these services every time I need to push a container is a pain. Fortunately, you can set up your .docker/config.json for each user to be able to seamlessly use multiple repositories.

For this to work you need the Google Cloud SDK installed, and also another tool called the ecr-credential-helper tool from Amazon. Once those are set up modify your .docker/config.json to use the specific repository helpers for each of the repositories. Your standard docker login command will base64 encode your auth string, anytime you try and connect to any of the Google endpoints, or your specific Amazon endpoint (using your repo URI), it will use the specific helper and appear seamless.

{
  
        "auths": {           
                "https://index.docker.io/v1/": {   
                        "auth": "YmluYXJ=="      
                }     
        }, 
        "HttpHeaders": { 
                "User-Agent": "Docker-Client/17.09.0-ce (linux)"
        },
        "credHelpers": {  
                "appengine.gcr.io": "gcr",   
                "asia.gcr.io": "gcr",          
                "eu.gcr.io": "gcr", 
                "gcr.io": "gcr",
                "gcr.kubernetes.io": "gcr", 
                "us.gcr.io": "gcr", 
                "1234567890.dkr.ecr.us-east-2.amazonaws.com": "ecr-login" 
        } 
}
#devops#docker#repositories#helpers

Unifi Controller on a Pi with Ansible

Migrating to Lambda from Cron Jobs