# Update docker images and re-run docker compose up

**URL:** <https://forum.ansible.com/t/update-docker-images-and-re-run-docker-compose-up/36636>\
**Category:** Ansible Project\
**Created:** [May 17, 2022, 8:33am UTC](https://forum.ansible.com/t/update-docker-images-and-re-run-docker-compose-up/36636 "2022-05-17T08:33:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thibaut\_Perrin1](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Thibaut\_Perrin1](https://forum.ansible.com/u/Thibaut_Perrin1)\
**Post date:** [May 17, 2022, 8:33am UTC](https://forum.ansible.com/t/update-docker-images-and-re-run-docker-compose-up/36636/1 "2022-05-17T08:33:59Z")

</div>

Hello,

I am working on automating my docker images updates.

For that I get a notification from DIUN, and so far I’m running the update with a simple bash scripts that goes through my docker stack folders, running a docker-compose ps to check if there are any processes, and if so, runs a docker-compose pull & docker compose up -d, which recreates the appropriate containers.

I found that I can do the pull quite easily (I think) by doing a docker\_host\_info to gather the information, and then use the resulting variable to run a loop on docker\_image, but I’m not sure on how to approach the docker-compose up on only already running stacks. Is there a condition I could use to do so? Or do I have to run a ps command manually for such a result?

Thanks,
