# How to create docker image with drone when code is modified in bitbucket repository

**URL:** <https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693>\
**Category:** Drone Support\
**Created:** [April 10, 2018, 6:25pm UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693 "2018-04-10T18:25:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sravan1265](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/sravan1265/32/4056_2.png) [@sravan1265](https://drone.discourse.group/u/sravan1265)\
**Post date:** [April 10, 2018, 6:25pm UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/1 "2018-04-10T18:25:28Z")

</div>

Hi Team,

I want build new docker image every time when the code is changed in repository. For that how to configure drone. i am not able to find any solution.  
Can you please help me in this.

Below is the drone installation docker-compose file and i have tested with sample .drone.yml and it is works fine.

version: ‘2’

services:  
drone-server:  
image: drone/drone:0.8

```
ports:
  - 80:8000
  - 9000
volumes:
  - /var/lib/drone:/var/lib/drone/
  - /etc/bitbucket/key.pem:/etc/bitbucket/key.pem
restart: always
environment:
  - DRONE_OPEN=true
  - DRONE_HOST=http://000.000.000.000
  - DRONE_STASH=true
  - DRONE_STASH_GIT_USERNAME=
  - DRONE_STASH_GIT_PASSWORD=
  - DRONE_STASH_CONSUMER_KEY=
  - DRONE_STASH_CONSUMER_RSA=
  - DRONE_STASH_URL=http://bitbucket.xxxxx.xxx:7990/bitbucket
  - DRONE_SECRET=FAD2JFkJEffgMjak6uQqJxKmv3HGD99L5xaz
  - DRONE_HOOK=http://000.000.000.000/hook

```

drone-agent:  
image: drone/agent

```
command: agent
restart: always
depends_on:
  - drone-server
volumes:
  - /var/run/docker.sock:/var/run/docker.sock
environment:
  - DRONE_SERVER=drone-server:9000
  - DRONE_SECRET=FkvGvSffgMjak6uQqJxKmv3HGD99L5xaz
```

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 10, 2018, 6:28pm UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/2 "2018-04-10T18:28:11Z")

</div>

> [@On another topic](https://drone.discourse.group/t/2082/1):
>
> I want build new docker image every time when the code is changed in repository. For that how to configure drone. i am not able to find any solution.

you would use the docker plugin for this, which handles building and publishing images:  
[http://plugins.drone.io/drone-plugins/drone-docker/](http://plugins.drone.io/drone-plugins/drone-docker/)

---

<div class="post-metadata">

**Author:** ![sravan1265](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/sravan1265/32/4056_2.png) [@sravan1265](https://drone.discourse.group/u/sravan1265)\
**Post date:** [April 10, 2018, 6:45pm UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/3 "2018-04-10T18:45:10Z")

</div>

Thanks for your quick response.  
But currently I want build images in my local mechine where drone is running.

Can you please help me in further.

Thanks

Sravan

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 10, 2018, 7:03pm UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/4 "2018-04-10T19:03:49Z")

</div>

You can mount the host machine docker socket and interact directly with the docker daemon:  
[http://docs.drone.io/docker-volumes/](http://docs.drone.io/docker-volumes/)

---

<div class="post-metadata">

**Author:** ![sravan1265](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/sravan1265/32/4056_2.png) [@sravan1265](https://drone.discourse.group/u/sravan1265)\
**Post date:** [April 11, 2018, 4:15am UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/5 "2018-04-11T04:15:58Z")

</div>

Thanks for your quick response. I will go through your links

Thanks  
Sravan

---

<div class="post-metadata">

**Author:** ![sravan1265](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/sravan1265/32/4056_2.png) [@sravan1265](https://drone.discourse.group/u/sravan1265)\
**Post date:** [April 16, 2018, 5:38am UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/6 "2018-04-16T05:38:39Z")

</div>

HI

I am facing issue with drone to create docker image. Below are the my file to configure drone and .drone.yml file create new docker image when any changes made in the bitbucket repository

version: ‘2’

services:  
drone-server:  
image: drone/drone:0.8

```
ports:
  - 80:8000
  - 9000
volumes:
  - /var/lib/drone:/var/lib/drone/
restart: always
environment:
  - DRONE_ADMIN=sravan
  - DRONE_OPEN=false

```

# - DRONE\_ADMIN=sravan

```
  - DRONE_HOST=http://
  - DRONE_GITHUB=true
  - DRONE_GITHUB_CLIENT=a3exxxxxxxxxxd2a33
  - DRONE_GITHUB_SECRET=5af4ff89c0f13xxxxxxxx4854625
  - DRONE_SECRET=taVfIELINoHSeCtmzGkxxxxxWVq6YwxxxxxjJ1faaNU96nqNuBeVUu

```

drone-agent:  
image: drone/agent:0.8

```
command: agent
restart: always
depends_on:
  - drone-server
volumes:
  - /var/run/docker.sock:/var/run/docker.sock
environment:
  - DRONE_SERVER=drone-server:9000
  - DRONE_SECRET=taVfIELINoHSfaaNU96nqNuBeVUu

```

##############################

below is the my sample .drone.yml file

pipeline:  
build:  
image: ubuntu:14.04  
commands:  
- docker build -t test123 .  
volumes:  
- /var/run/docker.sock:/var/run/docker.sock

Throwing **"Insufficient privileges to use volumes"**

Please help me to fix this

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 16, 2018, 5:46am UTC](https://drone.discourse.group/t/how-to-create-docker-image-with-drone-when-code-is-modified-in-bitbucket-repository/9693/7 "2018-04-16T05:46:51Z")

</div>

Please search the forum / google for existing topics related to this message [http://discuss.harness.io/search?q=Insufficient%20privileges%20to%20use%20volumes](http://discuss.harness.io/search?q=Insufficient%20privileges%20to%20use%20volumes)
