# How to build docker image?

**URL:** <https://forum.ansible.com/t/how-to-build-docker-image/17033>\
**Category:** Ansible Project\
**Created:** [December 11, 2014, 10:59pm UTC](https://forum.ansible.com/t/how-to-build-docker-image/17033 "2014-12-11T22:59:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shunsuke\_Mie](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@Shunsuke\_Mie](https://forum.ansible.com/u/Shunsuke_Mie)\
**Post date:** [December 11, 2014, 10:59pm UTC](https://forum.ansible.com/t/how-to-build-docker-image/17033/1 "2014-12-11T22:59:58Z")

</div>

I want to build docker image by ansible, but docker\_image is deprecated module.  
Can I be build in any way?

I couldn’t write english well, so this sentence is incorrect.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [December 12, 2014, 4:20am UTC](https://forum.ansible.com/t/how-to-build-docker-image/17033/2 "2014-12-12T04:20:13Z")

</div>

Hi Shunsuke, that module can still be used despite being deprecated, it just may be removed at some point in the future. An alternative would be to simply use the command module to run the build command directly. At some point, the functionality to build images may be moved into the docker module itself, so this should be a short-term solution.

Thanks!

---

<div class="post-metadata">

**Author:** ![Matt\_Silverlock](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@Matt\_Silverlock](https://forum.ansible.com/u/Matt_Silverlock)\
**Post date:** [April 25, 2015, 1:43am UTC](https://forum.ansible.com/t/how-to-build-docker-image/17033/3 "2015-04-25T01:43:00Z")

</div>

Just to see where this is at: I assume the docker\_image module is still being rolled into the docker module? ([http://docs.ansible.com/docker\_module.html](http://docs.ansible.com/docker_module.html))

- The ‘new’ canonical docker module is good, but doesn’t easily facilitate building images from a Dockerfile. You need to push to a Docker registry (Hub or private) first.

- This certainly sucks if you’re on a slow connection (uploading even 80MB @ 70KB/s upload = 19 minutes)

- Having Ansible build the image on the remote host (and handle passing files/scripts alongside the Dockerfile) to the docker build command running on the remote host is REALLY useful, and I’m hoping it doesn’t get lost in the move to the new module.  
I’m going to keep using the docker\_image module as much as I can but I still need to double-dip with the new module to run the containers/restart them/etc.
