Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to push docker image tagged after git branch?

Hi everyone!

We are in the middle of transition to bitbucket pipelines.

We build docker images from every git branch and run tests against these images. To make tracking of what image was build from what branch easier we tag docker images with git branch name it was built from.

The problem is that feature branches have slash "/' in their name and slash is not allowed in docker image tag. What we used to do is replace slashes with dashes and use that as a tag.

One option for us would be to use a script that does that substitution and pushes image, but we would have to put that script in every repository.

To use pipe atlassian/aws-ecr-push-image:1.2.2 we tried to define tags as


but it does not work and build fails with

Image not found: 404 Client Error: Not Found 
Image not found: 404 Client Error: Not Found ("no such image: whatever: No such image: whatever:latest")

 We also tried to add a separate step that does replacement and exports result as  another variable, but that did not work either.

Changing naming convention would cause a lot of pain, many scripts rely on existing scripts rely on that naming convention.

1 answer

1 accepted

0 votes
Answer accepted

@Sergey Mokhov I guess you want something like changing,e.g

feature/jira-story-333 to feature-jira-story-333.

You can define another local variable to substisute, BUT with proper escaping before executing pipe, like


 - deploy_tag="${BITBUCKET_BRANCH/\//-}"

- pipe: atlassian/aws-ecr-push-image:1.2.0



      TAGS: $deploy_tag


for me replacing worked all right:


echo "branch is" $branch
branch is feature-check-branch

Perhaps, passing such substitution right in the variables does not work, but try to initialize this variable and let's see. In the pipe we accept this variable as string and I am not sure it is acceptable to pass value as a variable and it will be transformed on the fly. So then try just with local var initializing.


Also, please share logs after the execution if it fails.

Regards, Galyna

Hi Galyna, thank you for your reply. Unfortunately it did not work.

- step: &build-deploy-pes-image
name: Build and push PES Docker image
- gradle
- gradlewrapper
- docker
- docker
- scripts/ "${BITBUCKET_BRANCH}"
- deploy_tag="${BITBUCKET_BRANCH/\//-}"
- echo "Deploy tag is ${deploy_tag}"
- pipe: atlassian/aws-ecr-push-image:1.2.2
TAGS: "${deploy_tag}"

Pipe image was called with


 And failed like that

Image not found: 404 Client Error: Not Found ("no such image: No such image:")

@Sergey Mokhov 

I just jave tried our pipe.

I am not sure how you setup your infra in AWS ECR, so just in case ensure that you take into account following details, that I did and it worked for me (firstly it also was failing with the same error you provided):


- your IMAGE_NAME should equal to repository name you created in AWS ECR

- when you go to your repository in AWS console and click push commands, it explains you what to do before push, the main thing is:

docker build -t <your_repository_name> .

So ensure you build that same image you're trying to push.


Everything else is our pipe can take care of, I suppose (for me it worked).

So my script is:

- step:
name: test ecr
- echo "Test ecr"
- echo "branch is" $BRANCH
- docker build -t bbci-pipes-test-ecr-239 .
- pipe: atlassian/aws-ecr-push-image:1.2.2
IMAGE_NAME: 'bbci-pipes-test-ecr-239'

And it worked. Screenshot is attached.

If it does not work, share more details about your setup and share full trace just in case, not just error output. This will help to debug your case.

Regards, Galyna


Screenshot from 2020-12-15 13-33-46.png

I do not know why it does not show my previous comments, but...

I tried image name with no aws url and it did not work either.

Image not found: 404 Client Error: Not Found ("no such image: pfpes-web: No such image: pfpes-web:latest")

@Sergey Mokhov

check the details I pointed to :

- if you name the image pfpes-web, the repository, that contains your images in aws should  be named pfpes-web.

- how you build your docker image in your scripts/ script?


These details matters, I have tried that and had the same error and then I fixed this with

* building image script fix

* naming image as the same that my remote repository.


Please, share with us these details about your setup in aws console and we can help to fix it, I don't see you provided them

Repository name matches image name exactly and it is pfpes-web.

The script builds image as:

docker build -t "${finalImageName}" .

 So the resulting image name looks like

I can push this image into ECR with

docker push "${dockerRegistryAddress}/${ecrRepoName}:${branchName}"

@Sergey Mokhov try to go with

finalImageName=pfpes-web // name of your repository
docker build -t ${finalImageName}

 THe point is , we are getting registry address in our pipe ourselves. We think it should make things simpler:

1. By your credentials pipe gets token from aws

2. Using token pipe discovers your registry and creds ITSELF.

So you don't need to type it in.


If that solution is not fine for you (when we discover your address ourselves by your creds inside the pipe and it is more safe in our opinion), within a team we can think about feature request to the pipe, sth like custom registry. In this case we would need from you more details to decide things about the implementation of such custom registry address.


But IMHO, if you have an ability to not show up such things in the pipeline, you can use this ability.

This is up to you, actually, if it is necessary for you to go with registry address, we can talk about this .


Waiting for your feedback!

Cheers, Galyna

Thank you Galina for your answers. I have not tried the last one you suggested, but pretty sure it would work.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

159 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you