# How to deploy a docker image automatically?

**URL:** <https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689>\
**Category:** Drone Support\
**Created:** [April 19, 2021, 8:11pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689 "2021-04-19T20:11:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![frauseo](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/frauseo/32/3284_2.png) [@frauseo](https://drone.discourse.group/u/frauseo)\
**Post date:** [April 19, 2021, 8:11pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/1 "2021-04-19T20:11:33Z")

</div>

Hi Community,

I’ve not found in the documentation how i can deploy a docker image from a private registry.  
I’ve set up a pipeline which builds a docker image and pushes it via docker plugin to my registry.  
What i want to achieve is a automated deployment when master branch is pushed through git.  
Here is my `.drone.yml`:

```auto
kind: pipeline
type: docker
name: build drone demo
steps:
  - name: build
    image: plugins/docker
    settings:
      username:
        from_secret: REGISTRY_USER
      password:
        from_secret: REGISTRY_PASSWORD
      storage_driver: vfs
      registry: my_registry
      repo: my_registry/test/drone
      tags:
        - latest

  - name: deploy
    pull: if-not-exists
    image: my_registry/test/drone
    settings:
      username:
        from_secret: REGISTRY_USER
      password:
        from_secret: REGISTRY_PASSWORD
    commands:
      - docker run -d -p 4444:80 --name drone-test my_registry/test/drone

image_pull_secrets:
- dockerconfig

```

When I pull the image and run the `docker run`-command, works fine. Drone just give me this error:

```auto
docker run -d -p 4444:80 --name drone-test my_registry/test/drone
/usr/drone/bin/init: line 17: docker: not found

```

I’ve no clue what this means and where to check for more detailed logs.

Thanks for the help and pointing to a documentation is highly appreciated!

cheers!

---

<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 19, 2021, 8:26pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/2 "2021-04-19T20:26:14Z")

</div>

```auto
line 17: docker: not found

```

The commands in your pipeline step are executed inside the specified docker image (this means, per your example, `docker run` is executed inside the `my_registry/test/drone` container). The above error therefore indicates you are attempting to execute a `docker` command inside a container that does not have docker installed.

---

<div class="post-metadata">

**Author:** ![johanvdw](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/johanvdw/32/3242_2.png) [@johanvdw](https://drone.discourse.group/u/johanvdw)\
**Post date:** [April 20, 2021, 12:02pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/3 "2021-04-20T12:02:34Z")

</div>

You could consider using:

> **[containrrr/watchtower](https://github.com/containrrr/watchtower)**
>
> A process for automating Docker container base image updates.

---

<div class="post-metadata">

**Author:** ![frauseo](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/frauseo/32/3284_2.png) [@frauseo](https://drone.discourse.group/u/frauseo)\
**Post date:** [April 20, 2021, 2:03pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/4 "2021-04-20T14:03:31Z")

</div>

Oh, I see. Thanks for pointing out this!  
So then is there no solution to deploy automatically a previous build Docker image from a regestry with Drone?

---

<div class="post-metadata">

**Author:** ![frauseo](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/frauseo/32/3284_2.png) [@frauseo](https://drone.discourse.group/u/frauseo)\
**Post date:** [April 20, 2021, 2:04pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/5 "2021-04-20T14:04:00Z")

</div>

This is basically what i want. So there is no Solution with Drone?

---

<div class="post-metadata">

**Author:** ![johanvdw](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/johanvdw/32/3242_2.png) [@johanvdw](https://drone.discourse.group/u/johanvdw)\
**Post date:** [April 20, 2021, 2:25pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/6 "2021-04-20T14:25:00Z")

</div>

You could get it working as well with a docker-in-docker image or with a drone exec pipeline.

From a security point of view, I would not recommend doing so. Allowing docker to run from inside a drone pipeline basically allows root access. That’s why you have to set a repo to trusted for it to work (for doid). I would also immediately set the protected mode which requires a signature on your pipeline.

---

<div class="post-metadata">

**Author:** ![frauseo](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/frauseo/32/3284_2.png) [@frauseo](https://drone.discourse.group/u/frauseo)\
**Post date:** [April 20, 2021, 6:46pm UTC](https://drone.discourse.group/t/how-to-deploy-a-docker-image-automatically/10689/7 "2021-04-20T18:46:46Z")

</div>

@bradrydzewski  
@johanvdw  
Thank you for sharing your knowledge with the community!  
Very appreciated!
