title: Private docker registry in cloud-init.yaml
body: <p>I have a private docker registry. Usually I have to login to the client machine and type <code>docker login &lt;private registry url&gt;</code></p>
  
  <p>I would like to deploy an AWS auto scaling dockerized environment but I am not sure how to ensure the docker commands to pull an image uses our private docker registry only. I was thinking to have it in cloud-init.yaml and setup </p>
  
  <pre><code>- path: /root/.docker/config.json
    content: |
       {
        "auths": {
            "&lt;private registry url&gt;": {
                "auth": "xxxxxxxxxxxxxxxxxx"
            }
        },
        "HttpHeaders": {
        "User-Agent": "Docker-Client/xyz (xyzzy)"
        }
    }
  </code></pre>
  
  <p>Is that the correct approach or is there a better way?</p>