Search code examples
amazon-ec2artifactoryautoscalingdocker-registry

Private docker registry in cloud-init.yaml


I have a private docker registry. Usually I have to login to the client machine and type docker login <private registry url>

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

- path: /root/.docker/config.json
  content: |
     {
      "auths": {
          "<private registry url>": {
              "auth": "xxxxxxxxxxxxxxxxxx"
          }
      },
      "HttpHeaders": {
      "User-Agent": "Docker-Client/xyz (xyzzy)"
      }
  }

Is that the correct approach or is there a better way?


Solution

  • Use an S3 bucket to hold your json configuration for registry configuration and set it up on boot.