无法让 AWS ecs-cli 从私有 docker 存储库中提取

Trouble getting AWS ecs-cli to pull from private docker repo

我正在尝试使用新的 AWS ecs-cli,但无法从私人 docker 存储库中提取它。我在 S3 存储桶中获得了我的 docker 凭据,但我将如何在 cli 中设置它?文档对此不是很清楚。我也不想开始 ssh-ing 进入实际实例,因为那样感觉不太干净。有什么想法吗?

我认为该特定功能仍然不可用:

https://github.com/aws/amazon-ecs-cli/issues/24

您只需在启动 ECS 代理之前设置 ECS_ENGINE_AUTH_TYPE 和 ECS_ENGINE_AUTH_DATA 环境变量。

我的集群主机是使用 cloudformation 配置的,这是 ECSServerLaunchConfig 块,它通过设置 ecs.config 文件中的变量将实例配置为从私有存储库中提取。我正在使用 AWS ECS 优化 AMI。

  "ECSServerLaunchConfig": {
  "Type": "AWS::AutoScaling::LaunchConfiguration",
  "Properties": {
    "IamInstanceProfile" : { "Fn::GetAtt" : ["InstanceProfile", "Arn"] },
    "ImageId" : { "Ref" : "AgentAMI" },
    "InstanceType": "c4.large",
    "SpotPrice": { "Ref": "SpotPrice" },
    "KeyName"  : { "Fn::GetAtt" : ["KeyPair", "Name"] },
    "SecurityGroups": [ { "Ref": "ECSServerSecurityGroup" } ],
    "BlockDeviceMappings" : [
      {
        "DeviceName" : { "Ref" : "EbsDeviceName" },
        "Ebs" : {
          "VolumeSize" : { "Ref" : "EbsDeviceSize" }
        }
      }
    ],
    "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
      "#!/bin/bash\n",
      "mkfs -t ext4 /dev/xvdk\n",
      "mkdir /data\n",
      "mount /dev/xvdk /data\n",
      "chmod -R 777 /data\n",
      "yum install -y perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA\n",
      "yum install -y wget\n",
      "yum install -y unzip\n",
      "cd /home/ec2-user\n",
      "wget http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip\n",
      "unzip CloudWatchMonitoringScripts-1.2.1.zip\n",
      "echo \"*/1 * * * * /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-util --disk-space-util --disk-path=/ --disk-path=/data --auto-scaling --from-cron\" >> mycron\n",
      "crontab mycron\n",
      "echo ECS_CLUSTER=", { "Ref" : "ECSCluster" }, " >> /etc/ecs/ecs.config\n",
      "echo ECS_ENGINE_AUTH_TYPE=dockercfg >> /etc/ecs/ecs.config\n",
      "echo ECS_ENGINE_AUTH_DATA='{\"https://index.docker.io/v1/\":{\"auth\":\"", { "Ref" : "PrivateRegistryAuthCode" },
          "\",\"email\":\"", { "Ref" : "PrivateRegistryEmail" }, "\"}}' >> /etc/ecs/ecs.config\n",
      "echo 'OPTIONS=\"--default-ulimit nofile=1024:4096 --mtu=1500\"' >> /etc/sysconfig/docker\n",
      "service docker restart\n",
      "start ecs"
    ]]}}
  }
},