Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,506
Community Members
 
Community Events
165
Community Groups

[Pipelines] Build docker image in bitbucket-pipelines.yml

Heyy,

In my bitbucket-pipelines.yml, I want to be able to build a docker image in my step/script (docker build -t myTag .). To do that I use an image allowing me to do docker in docker (jeroenknoops/docker-docker-dind-bash). However, to build the image, I need the container to be started with the option "-v /var/run/docker.sock:/var/run/docker.sock". Is there a way to do that ? Is there another way to build a docker image from the script?

Thanks for your help!

3 answers

3 votes
SebC Atlassian Team Apr 17, 2017
1 vote
Tom Bradshaw Atlassian Team Jun 21, 2016

Hi Matthieu,

It is possible to build a docker image externally and reference it by adding 

image: yourdockerusername/imagename

with the appropriate values to your yaml file (as specified here https://answers.atlassian.com/questions/39140980). Unfortunately there is no way of running docker in docker regardless of image used. This means it is not possible to build docker images from the script.

Deleted user Jul 19, 2016

Hello Thomas,

I believe what Matthieu is looking to do (and I am as well) is what is described in the last section of this article. The hope is that this would actually allow the creation of a docker image from within the script (which could then be pushed to a docker registry, deployed, etc.). I did a little testing locally, and running the docker image as follows did allow me to create docker images from within docker.

docker run -v /var/run/docker.sock:/var/run/docker.sock -ti docker

I'm just starting to experiment with docker deployment strategies, but I am curious if there is any way to add the ability to bind the docker socket on the image used by Pipelines?

Thanks for your help!

Justin

Like soroush_kazemi likes this

Hey Justin,

unfortunately Bitbucket Pipelines doesn't support yet the building of Docker images as part of your build. 

We do however hope to get this functionality added soon. You can find the open feature request here: https://bitbucket.org/site/master/issues/12790/building-and-pushing-docker-images

Deleted user Jul 21, 2016

Hi Jeroen,

 

Alright, thanks for pointing out the feature request! I'll keep an eye on that.

 

Justin

This is kind of a late comment from me, but you can ln -s the docker socket to inside your $BITBUCKET_CLONE_DIR and refer to that as a volume.

Like Brahim FOURA likes this

Also an update: Docker build and push (and other operations) are now supported by Pipelines: https://blog.bitbucket.org/2017/04/18/bitbucket-pipelines-supports-building-docker-images-and-service-containers/ 

@sandorvasas Do you have an example using ln -s

For weird reason, the forum won't let me post my question; so posting a link to my question in StackOverflow:

https://stackoverflow.com/questions/44146389/bitbucket-pipelines-docker-unauthorized-authentication-required-docker-push

This issue is really puzzling and I wonder if anyone can drop in an insight. Thanks!

 

Suggest an answer

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

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,181 views 2 9
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