Plugins/ecr does not auto-create repo in ECR

Not exactly certain how this works, but looks like the plugins/ecr drone plugin will auto-create the ecr repository if it does not exist. Trying to get this setup, but I am getting an exit code 1 at the publish step. Curious if there was a way to debug

pipeline:
  build:
    image: me/my-docker-images
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    commands:
      - docker-compose build

  publish:
    image: plugins/ecr
    repo: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/my-awesome-app
    tags:
      - latest
    create_repository: true
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

See http://docs.drone.io/why-does-the-docker-plugin-fail/ for troubleshooting steps.

Also note that mounting the host machine docker socket for the ECR plugin is not required or recommended and is likely the reason for the failure. The ECR plugin starts its own docker-in-docker daemon. Mounting the socket is causing the docker-in-docker daemon to fail to start and therefore causing the plugin to exist. The debug: true parameter, described in the troubleshooting guide above, would likely confirm this.

I posted this wrong I think. Seems I don’t the the exit code 1 when I mount the docker socket. Is it preferred to not share the docker socket when building images with drone? And is there anything I need to do for the drone-agent to run DinD, like privileged: true?

pipeline:
  publish:
    debug: true
    image: plugins/ecr
    repo: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/my-awesome-app
    tags:
      - latest
    create_repository: true
{"time":"2017-11-21T17:36:31Z","level":"debug","message":"request next execution"}
{"time":"2017-11-21T17:36:39Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"received execution"}
{"time":"2017-11-21T17:36:39Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"listen for cancel signal"}
{"time":"2017-11-21T17:36:39Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","exit_code":0,"exited":false,"message":"update step status"}
{"time":"2017-11-21T17:36:39Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","exit_code":0,"exited":false,"message":"update step status complete"}
{"time":"2017-11-21T17:36:40Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","message":"log stream opened"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","message":"log stream copied"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","message":"log stream uploading"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","message":"log stream upload complete"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","message":"log stream closed"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","exit_code":0,"exited":true,"message":"update step status"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/git:latest","stage":"clone","exit_code":0,"exited":true,"message":"update step status complete"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","exit_code":0,"exited":false,"message":"update step status"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","exit_code":0,"exited":false,"message":"update step status complete"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","message":"log stream opened"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","message":"log stream copied"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","message":"log stream uploading"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","message":"log stream upload complete"}
{"time":"2017-11-21T17:36:41Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","message":"log stream closed"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","exit_code":1,"exited":true,"message":"update step status"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","image":"plugins/ecr:latest","stage":"publish","exit_code":1,"exited":true,"message":"update step status complete"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","error":"","exit_code":1,"message":"pipeline complete"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"uploading logs"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"uploading logs complete"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","error":"","exit_code":1,"message":"updating pipeline status"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"stop listening for cancel signal"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"updating pipeline status complete"}
{"time":"2017-11-21T17:36:42Z","level":"debug","message":"request next execution"}
{"time":"2017-11-21T17:36:42Z","level":"debug","repo":"me/my-awesome-app","build":"2239","id":"9407","message":"pipeline done"}

:point_up_2: I think some of this was mentioned above. You do not need any special configuration above and beyond what is documented here http://plugins.drone.io/drone-plugins/drone-ecr/

It looks due to setting the create_repository flag. Setting it either as an environment variable ECR_CREATE_REPOSITORY=true or as custom yaml create_repository: true option results in the exit code 1. Removing those options makes the plugin work, but errors ofcourse because the repo does not exist

I am not the plugin creator and do not personally use ECR, so the best I can do is point you to the source code https://github.com/drone-plugins/drone-docker/blob/master/cmd/drone-docker-ecr/main.go

1 Like

You probably have an I AM issue.

Is it the goal that drone-plugins/drone-docker will handle everything that drone-plugins/drone-ecr does?

Is it the goal that drone-plugins/drone-docker will handle everything that drone-plugins/drone-ecr does?

Yes. A community member ported the plugin from bash to go. If you think you have found a regression please consider sending a pull request.