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

how to use bitbucket pipeline with docker

nexus_hardik June 12, 2019

Hello,

 

I m new here.

i want to know about how i can use bitbucket pipeline that build docker image with bitbucket repo and then push to dockerhub.

 

please guide me.

thank you.

1 answer

0 votes
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 13, 2019

Hello Hardik,

You can use Docker in Pipelines, in a similar manner to how you do so locally.

Here's an example bitbucket-pipelines.yml configuration that enables Docker, and does a build and push.

pipelines:
default:
- step:
services:
- docker # Enables Docker in this specific step of your pipeline.
script:
- docker build -t my-image:version .
- docker login -u dockerhub_username -p $DOCKER_PASSWORD
- docker push my-image:version

I recommend that you use secured variables for your DockerHub password, so that it doesn't show in the logs.

We have more details information about Docker inside of Pipelines here: https://confluence.atlassian.com/bitbucket/run-docker-commands-in-bitbucket-pipelines-879254331.html

If you're still new to Docker, I recommend you work through the Docker tutorials locally to get comfortable with how it works first: https://docs.docker.com/get-started/

Thanks,

Phil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events