Search code examples
amazon-web-servicesdockeramazon-elastic-beanstalk

Deploy image to AWS Elastic Beanstalk from private Docker repo


I'm trying to pull Docker image from its private repo and deploy it on AWS Elastic Beanstalk with the help of Dockerrun.aws.json packed in zip. Its content is

{
    "AWSEBDockerrunVersion": "1",
    "Authentication": {
        "Bucket": "my-bucket",
        "Key": "docker/.dockercfg"
    },
    "Image": {
        "Name": "namespace/repo:tag",
        "Update": "true"
    },
    "Ports": [
        {
            "ContainerPort": "8080"
        }
    ]
}

Where "my-bucket" is my bucket's name on s3, which uses the same location as my BS environment. Configuration that's set in key is the result of

$ docker login

invoked in docker2boot app's terminal. Then it's copied to folder "docker" in "my-bucket". The image exists for sure. After that I upload .zip with dockerrun file to EB and on deploy I get

Activity execution failed, because: WARNING: Invalid auth configuration file

What am I missing? Thanks in advance


Solution

  • Docker has updated the configuration file path from ~/.dockercfg to ~/.docker/config.json. They also have leveraged this opportunity to do a breaking change to the configuration file format.

    AWS however still expects the former format, the one used in ~/.dockercfg (see the file name in their documentation):

    {
      "https://index.docker.io/v1/": {
        "auth": "__auth__",
        "email": "__email__"
      }
    }
    

    Which is incompatible with the new format used in ~/.docker/config.json:

    {
        "auths": {
            "https://index.docker.io/v1/": {
                "auth": "__auth__",
                "email": "__email__"
            }
        }
    }
    

    They are pretty similar though. So if your version of Docker generates the new format, just strip the auths line and its corresponding curly brace and you are good to go.