We use a custom docker image for the build step and this image should be pulled from AWS ECR. I searched this forum and came across solutions that pull the image in one step to make it available in the next step but is doesn’t seem to work for me. Here is my .drone.yml
:
---
kind: pipeline
name: default
volumes:
- name: docker
host:
path: /var/run/docker.sock
steps:
- name: Pull build-container-ansible
image: docker.io/mludvig/docker-builder
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- aws --region ap-southeast-2 ecr get-login --no-include-email --registry-ids 123456789012 | sh
- docker pull 123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/build-container-ansible:latest
- docker images
- name: Custom image
image: 123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/build-container-ansible:latest
volumes:
- name: docker
path: /var/run/docker.sock
commands:
- ansible --version
The first step works and pulls the container from ECR:
+ aws --region ap-southeast-2 ecr get-login --no-include-email --registry-ids 123456789012 | sh
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
+ docker pull 123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/build-container-ansible:latest
latest: Pulling from build-container-ansible
Digest: sha256:997671bbaea...9e21a94484d47
Status: Image is up to date for 123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/build-container-ansible:latest
+ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
drone/drone 1.2.1 c9e98faa9680 5 days ago 63.2MB
plugins/slack latest 5dfdbac184c1 2 weeks ago 9.26MB
mludvig/docker-builder latest cb7cbfa59113 2 weeks ago 599MB
amazon/amazon-ecs-agent latest 267bac512a39 5 weeks ago 57.1MB
amazon/amazon-ecs-pause 0.1.0 54d8403124ce 5 weeks ago 954kB
plugins/ansible latest e43b2eee175f 7 weeks ago 201MB
plugins/git latest 90e2d8d126d9 3 months ago 66.3MB
drone/git latest 00d7b517c0b9 5 months ago 67.6MB
123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/build-container-ansible latest dae4f9c3a6ac 11 months ago 1.19GB
On the last the image is there. When I login to the EC2 instance it’s indeed in the docker images
list.
However the next pipeline step that should be using the builder-docker-ansible
fails:
default: Error response from daemon: Get https://123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/v2/build-container-ansible/manifests/latest: no basic auth credentials
default – Custom image: Failure
I can’t figure out why it doesn’t use the image pulled in the first step and keeps reaching out to ECR?
We are using Drone 1.2.1 in a single-server configuration, no agents.
Any ideas?
Thanks!