# Question on force\_source in community.docker.docker\_image

**URL:** <https://forum.ansible.com/t/question-on-force-source-in-community-docker-docker-image/35462>\
**Category:** Ansible Project\
**Created:** [July 5, 2021, 9:17am UTC](https://forum.ansible.com/t/question-on-force-source-in-community-docker-docker-image/35462 "2021-07-05T09:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafal\_Skolasinski](https://avatars.discourse-cdn.com/v4/letter/r/a87d85/32.png) [@Rafal\_Skolasinski](https://forum.ansible.com/u/Rafal_Skolasinski)\
**Post date:** [July 5, 2021, 9:17am UTC](https://forum.ansible.com/t/question-on-force-source-in-community-docker-docker-image/35462/1 "2021-07-05T09:17:39Z")

</div>

Hi,

I have a question on how the `force_source` works in `community.docker.docker_image` in case of pulling docker image.

Assuming that I already have a `my-awesome-stuff/my-image:my-tag` locally and run ansible playbook with task

```yaml

- name: "Pull docker image"
community.docker.docker_image:
name: "my-awesome-stuff/my-image:my-tag"
state: present
source: pull
force_source: yes

```

which of the following will happen:

a) - ansible sees that image is present but calls `docker pull` logic anyway

- docker pull realises that image is the same so no download happens

b) ansible notices `foruce_source` flag so download happens even if not required

The context I am interested in is if in the hub there is some tag that is rolling, `-dev` for example, and I want to insure that if the image will be updated in the hub then new version would be pulled but at the same time avoid unnecessary pulls.

Bonus question: how does the behaviour changes if the tag is `latest`?

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [July 5, 2021, 10:30am UTC](https://forum.ansible.com/t/question-on-force-source-in-community-docker-docker-image/35462/2 "2021-07-05T10:30:46Z")

</div>

Hi,

> I have a question on how the `force_source` works in  
> `community.docker.docker_image` in case of pulling docker image.
> 
> Assuming that I already have a `my-awesome-stuff/my-image:my-tag`  
> locally and run ansible playbook with task
> 
> ```yaml
> - name: "Pull docker image"
> community.docker.docker_image:
> name: "my-awesome-stuff/my-image:my-tag"
> state: present
> source: pull
> force_source: yes
> 
> ```
> 
> which of the following will happen:
> 
> a) - ansible sees that image is present but calls `docker pull` logic  
> anyway  
> &nbsp;&nbsp;&nbsp;&nbsp;- docker pull realises that image is the same so no download  
> happens
> 
> b) ansible notices `foruce_source` flag so download happens even if  
> not required

a) will happen. Then Ansible will process the `docker pull` log and  
notice that nothing was pulled, and will return changed=False.

> Bonus question: how does the behaviour changes if the tag is  
> `latest`?

The behavior does not depend on the tag's name.

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Rafal\_Skolasinski](https://avatars.discourse-cdn.com/v4/letter/r/a87d85/32.png) [@Rafal\_Skolasinski](https://forum.ansible.com/u/Rafal_Skolasinski)\
**Post date:** [July 5, 2021, 10:36am UTC](https://forum.ansible.com/t/question-on-force-source-in-community-docker-docker-image/35462/3 "2021-07-05T10:36:22Z")

</div>

Thank you Felix, exactly what I needed!
