[solved] Build and publish docker images to aws ECR

i read that we can use plugins/ecr to build and publish docker images to ecr since it is made on docker. i have my pipeline steps as follow:

steps:

  • name: build-auth
    image: plugins/ecr
    settings:
    access_key:
    from_secret: aws_access_key_id
    secret_key:
    from_secret: aws_secret_access_key
    repo: cloudvista
    registry: xxxxxxxxxxxxx.dkr.ecr.us-east-2.amazonaws.com
    tags: ${DRONE_COMMIT:0:7}
    commands:
    • docker build -t cloudvista/auth/${DRONE_COMMIT:0:7} .

and i am getting following error:

or this: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

please help as this is blockhead for me, thanks

Hmm, not sure about how the ECR plug-in encapsulates, but I used the ECR plug-in today
to deploy to ECR and then into AWS App Runner.

Blog:

GitHub:

-Ravi

@frankhills you cannot define “commands” for plugin steps. When you define commands, you override the entrypoint of the plugin image, which prevents the plugin from executing.

@bradrydzewski how can we build image using this plugins i want to do following actions:

  • build my docker image and tag them
  • publish them in ecr.

when i remove command from my step the pipeline is successful but the thing is i don’t see building any docker image and publish them in ecr do we need to add some step or lines in settings?

the plugin automatically runs docker build and docker publish. See this tutorial that Ravi published that walks through the process, and includes screenshots.

1 Like

thank @ravi.lachhman but i need to build and then push it in ecr, i have setting as follow:
steps:

  • name: build-auth
    image: plugins/ecr
    settings:
    access_key:
    from_secret: aws_access_key_id
    secret_key:
    from_secret: aws_secret_access_key
    repo: cloudvista
    registry: xxxxxxxxxxx.dkr.ecr.us-east-2.amazonaws.com
    tags: ${DRONE_COMMIT:0:7}

but i don’t see any image building and pushing into ecr

@bradrydzewski and how do we do this for multiple directories containing dockerfile such as:
folder1/dockerfile
folder2/dockerfile

You would create two separate steps, one for each dockerfile. You can then specify in your settings which dockerfile each individual step should use (see this example which does something similar).

1 Like

thank you @bradrydzewski and @ravi.lachhman for your guidance it helped me a lot! <3

@bradrydzewski can you suggest steps or guide me to pull image from ecr since i need it in different pipelines and by default aws ecr docker token is only validate for 12 hours and “dockerconfigjson” do not seems to work.

I can see you created a new thread to discuss pulling images from ecr, so lets move any discussion about pulling images to Pulling image from ECR