I call this pipe with "TAGS" but it always defaults to "latest".
As per below I'm using tag 1.1.1. Same problem with 1.1.0.
- pipe: atlassian/aws-ecr-push-image:1.1.1
variables:
TAGS: mytag
IMAGE_NAME: "${IMAGE}"
INFO: Executing the aws-ecr-push-image pipe...
INFO: Found credentials in environment variables.
INFO: Successfully logged in to https://xxx.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
✖ Image not found: 404 Client Error: Not Found ("no such image: myimage: No such image: myimage:latest")
Just in case it helps anyone, this is what worked for me -
script:
# Note that AWS picks up the registry name from the access key so not included in the repo name
- export REPOSITORY_NAME=myorg/myapp
- export TAG=${SEMVER}_${BITBUCKET_BUILD_NUMBER}
- docker build -t $REPOSITORY_NAME .
- pipe: atlassian/aws-ecr-push-image:1.2.1
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: $REPOSITORY_NAME
TAGS: '${TAG}'
Hi @michael_hart , it seems like the docker daemon can't find the image with the name 'myimage:latest' when running the pipe. You need to build this image in the same step before executing the pipe so it's available to docker.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I don't want to push "myimage:latest", I want to push "myimage:mytag"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right, the pipe will tag the myimage:latest with myimage:mytag and push the tagged image. But for this the pipe expects the myimage to be available for tagging. Here is an example
script:
# build the image
- docker build -t my-docker-image .
# use the pipe to push to AWS ECR
- pipe: atlassian/aws-ecr-push-image:0.2.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image
TAGS: '${BITBUCKET_TAG} latest'
In the above example, we build the image with the my-docker-image name and the pipe will tag it with two tags: ${BITBUCKET_TAG} (which might be something like 1.0.0 or other version) and latest.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I already build my image with this for example
docker build -t my-docker-image .
After which, I want to retag the image with "mytag" and only push my-docker-image:mytag to ECR. So in your example I'm doing the equivalent of this:
# use the pipe to push to AWS ECR
- pipe: atlassian/aws-ecr-push-image:0.2.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-docker-image
TAGS: '${BITBUCKET_TAG}'
However you'll find that, no matter what I put in "TAGS", it will always try to push "latest".
(in your example code, does that actually work?)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexander Zhukov I also seem to be having this issue. My script is as follows:
script:
- docker build -t my-image .
- pipe: atlassian/aws-ecr-image-push:1.1.3
variable:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
IMAGE_NAME: my-image
TAGS: '${BITBUCKET_BUILD_NUMBER}'
No matter what I seem to put in TAGS when it pushes my image it only ever tags it with 'latest'. I even tried something like `TAGS: "hi latest"` and I can see in the logs of the pipeline that the following is being set:
--env=TAG="hi latest"
But the image is still just tagged as `latest` in ECR. Am I missing something?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right, the pipe will tag the myimage:latest with myimage:mytag and push the tagged image.
Why would you do this? I provide the tag to be pushed but the pipe still expects to find a tag "latest" just to re-tag it to my provided tag? This just leads to confusion in the end. It's also not documented that the tag "latest" must be present even when pushing another tag.
The same for the image name. I have to build my image as "foo" just to get it pushed as `xxx.dkr.ecr.us-east-1.amazonaws.com/foo`. This breaks usual Makefiles for no reason. I don't think it's smart for this pipe trying to be "smart". I can figure out and provide image names by myself.
It's weird.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, `IMAGE_NAME` can have a tag. I'm currently experimenting with the equivalent of this, and it works:
- IMAGE_NAME=foo
- VERSION=2.3.4
- ECR_NS=staging
- TAG="${IMAGE_NAME}:${VERSION}"
- docker build --tag ${TAG} .
- docker tag ${TAG} ${ECR_NS}/${TAG}
- pipe: atlassian/aws-ecr-push-image:1.2.1
variables:
IMAGE_NAME: "${ECR_NS}/${TAG}"
TAGS: '${VERSION} bld-${BITBUCKET_BUILD_NUMBER}'
(Ok, this was just for experimenting, I'm not really using it. But it works, and no "latest" is tagged/pushed.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alexander's answer actually works.
I happened to have the same issue with the following script. No matter what I put in the TAGS, it always tried to push the image with "latest" tag.
- docker build -t $DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT .
- docker tag $DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT $DOCKER_ECR_REPO_URL/$DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT
- pipe: atlassian/aws-ecr-push-image:1.1.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID # Optional if already defined in the context.
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Optional if already defined in the context.
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION # Optional if already defined in the context.
IMAGE_NAME: $DOCKER_IMAGE_NAME
TAGS: '${BITBUCKET_COMMIT}' # Optional
However, Once I remove the tagging part, everything works like a charm. In the ECR, it tagged as expected.
- docker build -t $DOCKER_IMAGE_NAME .
- pipe: atlassian/aws-ecr-push-image:1.1.2
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID # Optional if already defined in the context.
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Optional if already defined in the context.
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION # Optional if already defined in the context.
IMAGE_NAME: $DOCKER_IMAGE_NAME
TAGS: '${BITBUCKET_COMMIT}' # Optional
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.