<p>You can utilize watchtower to restart the specified containers each time new image of that container is avaialble.</p>
<blockquote>
<p><a href="https://github.com/containrrr/watchtower" rel="nofollow noreferrer">Watchtower</a> : with watchtower you can update the running version
of your containerized app simply by pushing a new image to the Docker
Hub or your own image registry. Watchtower will pull down your new
image, gracefully shut down your existing container and restart it
with the same options that were used when it was deployed initially.
Run the watchtower container with the following command:</p>
<pre><code>$ docker run -d \
    --name watchtower \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower
</code></pre>
</blockquote>
<p>docker-compose integration example:</p>
<pre><code>services:
  watchtower:
    command: --label-enable --cleanup --interval 300
    image: containrrr/watchtower
    labels:
      - &quot;com.centurylinklabs.watchtower.enable=true&quot;
    network_mode: none
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  mariadb:
      depends_on:
        - watchtower
      env_file: .mariadb.env
      image: mariadb:10
      labels:
        - &quot;com.centurylinklabs.watchtower.enable=true&quot;
      networks:
        - default
      ports:
        - 3306:3306
      restart: always
      volumes:
        - ./data/volumes/mariadb:/var/lib/mysql
</code></pre>
<p>To check the logs of the updation you can execute <code>docker-compose logs watchtower</code></p>
<p>docker-compose integration reference: <a href="https://chriswiegman.com/2019/12/keeping-docker-containers-updated/" rel="nofollow noreferrer">https://chriswiegman.com/2019/12/keeping-docker-containers-updated/</a></p>

CC BY-SA 4.0
2020-11-27T07:03:37.173Z
2020-11-27T07:03:37.173Z
Ash Ishh
<p>I have 3 separate repositories, which contains API, web app, and Admin projects. All 3 runs on a Digital Ocean docker machine, and I deploy the 3 using docker-compose (I want to keep things simple).</p>
<p>Every time a push to master with a tag happen, GithubActions build each separate project and publish a docker image (with the corresponding tag), and then I manually launch <code>docker compose up -d</code>. The docker compose file point to the latest version of each image, so it get automatically reloaded and launched.</p>
<p>Is there a better way to automatically reload the docker compose from GitHub Actions? I ideally want that each time a repository build an image and push it to the registry, the docker compose automatically reload.</p>

<docker><docker-compose><github>
Deploy Docker Compose from different repositories
Pablosproject
# Deploy Docker Compose from different repositories

(Asked by: username_0 on 2020-11-25)

I have 3 separate repositories, which contains API, web app, and Admin projects. All 3 runs on a Digital Ocean docker machine, and I deploy the 3 using docker-compose (I want to keep things simple).

Every time a push to master with a tag happen, GithubActions build each separate project and publish a docker image (with the corresponding tag), and then I manually launch `docker compose up -d`. The docker compose file point to the latest version of each image, so it get automatically reloaded and launched.

Is there a better way to automatically reload the docker compose from GitHub Actions? I ideally want that each time a repository build an image and push it to the registry, the docker compose automatically reload.

**Tags:** docker, docker-compose, github


---

## 1 answers

### Answer by username_1 on 2020-11-27. Score: 2

You can utilize watchtower to restart the specified containers each time new image of that container is avaialble.

Watchtower : with watchtower you can update the running version
of your containerized app simply by pushing a new image to the Docker
Hub or your own image registry. Watchtower will pull down your new
image, gracefully shut down your existing container and restart it
with the same options that were used when it was deployed initially.
Run the watchtower container with the following command:
$ docker run -d \
    --name watchtower \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower


docker-compose integration example:
services:
  watchtower:
    command: --label-enable --cleanup --interval 300
    image: containrrr/watchtower
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
    network_mode: none
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  mariadb:
      depends_on:
        - watchtower
      env_file: .mariadb.env
      image: mariadb:10
      labels:
        - "com.centurylinklabs.watchtower.enable=true"
      networks:
        - default
      ports:
        - 3306:3306
      restart: always
      volumes:
        - ./data/volumes/mariadb:/var/lib/mysql

To check the logs of the updation you can execute docker-compose logs watchtower
docker-compose integration reference: https://chriswiegman.com/2019/12/keeping-docker-containers-updated/


---

