# How to build new image using existing Dockerfile?

**URL:** <https://drone.discourse.group/t/how-to-build-new-image-using-existing-dockerfile/10002>\
**Category:** Drone Support\
**Created:** [April 4, 2018, 6:49pm UTC](https://drone.discourse.group/t/how-to-build-new-image-using-existing-dockerfile/10002 "2018-04-04T18:49:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gr33ny](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@Gr33ny](https://drone.discourse.group/u/Gr33ny)\
**Post date:** [April 4, 2018, 6:49pm UTC](https://drone.discourse.group/t/how-to-build-new-image-using-existing-dockerfile/10002/1 "2018-04-04T18:49:52Z")

</div>

Hey!

I got issue with make .drone.yml file.  
I have existing Dockerfile on machine where working my drone server.

Now I want build new image using this Dockerfile, when somebody push changes to repository.

```
pipeline:
  build:
    image: "/tmp/Dockerfile" 

```

and different solutions using `compose` directive not working.  
Also I can’t find example and any information.

Have you an idea to do this?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![JaredReisinger](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/jaredreisinger/32/3692_2.png) [@JaredReisinger](https://drone.discourse.group/u/JaredReisinger)\
**Post date:** [May 1, 2018, 6:22pm UTC](https://drone.discourse.group/t/how-to-build-new-image-using-existing-dockerfile/10002/2 "2018-05-01T18:22:53Z")

</div>

You probably need to start with a clear understanding about how the Drone pipeline works, what the `image` property means, and so on. I haven’t found any “fundamental Drone concepts” documentation, but start by taking a look at the documentation about [Pipelines](http://docs.drone.io/pipelines/) and [Images](http://docs.drone.io/images/), and then take a look at the existing [Plugin Marketplace](http://plugins.drone.io/) (a slight misnomer, as you don’t have to pay).

For every step in the pipeline, the `image` property tells Drone about an _already built_ image that it should use to perform the actions you want. In your case, you want to “build a docker image”, so the build step should make use of the [Docker plugin](http://plugins.drone.io/drone-plugins/drone-docker/). More than likely, your `.drone.yml` file will end up looking something like:

```auto
pipeline:
  build:
    image: plugins/docker # <=== this is the plugin the "build" step uses
    dockerfile: /tmp/Dockerfile # <=== this is your Dockerfile, so the plugin can find it

```

In addition to building the Docker image, you need to publish it to a registry somewhere, otherwise you won’t be able to make use of the newly-built image. The Docker plugin can also do this for you, if you’re publishing to the default Docker registry. If you’re using AWS or GCR or some other registry, you might need to use a different plugin instead of “docker”… it all depends on your particular scenario.

---

<div class="post-metadata">

**Author:** ![JaredReisinger](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/jaredreisinger/32/3692_2.png) [@JaredReisinger](https://drone.discourse.group/u/JaredReisinger)\
**Post date:** [May 1, 2018, 6:24pm UTC](https://drone.discourse.group/t/how-to-build-new-image-using-existing-dockerfile/10002/3 "2018-05-01T18:24:22Z")

</div>

@bradrydzewski: This topic probably belongs in “General Discussion”, but I haven’t been active enough here to have those privileges yet. Thanks!
