Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to build and push Docker image using pipeline

Serge Asmar May 23, 2023

 

Hello everyone, 

I am trying to create an automated docker image build using pipelines, but i keep running into the same error: 

 

+ docker version
2
bash: docker: command not found
----------------------------------------
i also get the following error when i try something else: 
denied: requested access to the resource is denied
*---------------------------------------Screenshot (205).png
I'm guessing docker is either not available in bitbucket, or i have something that's off in my bitbucket-pipelines.yml
I will upload the error + .yml file, along with the link to my repository 
Any help and guidance is much appreciatedScreenshot (203).pngScreenshot (204).png

1 answer

1 accepted

0 votes
Answer accepted
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2023

Hi @Serge Asmar 

Looks like you are missing the service definition. 

Have a look here: https://support.atlassian.com/bitbucket-cloud/docs/run-docker-commands-in-bitbucket-pipelines/

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 25, 2023

Hello @Serge Asmar ,

Just adding to @Erez Maadani 's comment, in the first pipeline screenshot I'm seeing the error : 

The push refers to repository [docker.io/library/first_pipeline_img_build]
[...]
denied: requested access to the resource is denied

This is because when you built the docker image with docker build you provided the tag (-t) with just the image name but not the docker hub namespace where you want to push this image to. This makes docker default to library namespace, and your docker hub account doesn't seem to have access to that namespace/account.

In this case, I would recommend updating your docker build command to include the namespace/account into the tag, like the following example : 

docker build -t mydockerhubuser/first_pipeline_img_build .

In the above example, we are using the docker hub account mydockerhubuser. This is the account under which the image will be pushed when you run a docker push.

Thank you, @Serge Asmar !

Patrik S!

Serge Asmar May 26, 2023

Awesome thanks guys!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events