# Add option to docker\_container module to copy file into container directly

**URL:** <https://forum.ansible.com/t/add-option-to-docker-container-module-to-copy-file-into-container-directly/24732>\
**Category:** Ansible Developer\
**Created:** [June 15, 2017, 8:05am UTC](https://forum.ansible.com/t/add-option-to-docker-container-module-to-copy-file-into-container-directly/24732 "2017-06-15T08:05:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton\_Bormotov](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Anton\_Bormotov](https://forum.ansible.com/u/Anton_Bormotov)\
**Post date:** [June 15, 2017, 8:05am UTC](https://forum.ansible.com/t/add-option-to-docker-container-module-to-copy-file-into-container-directly/24732/1 "2017-06-15T08:05:06Z")

</div>

Sometimes, I have to copy files into running docker container.  
Would it make sense to add option to “docker\_container” module, for example “cp\_file”?  
If so, how can I contribute?  
Thanks,

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 15, 2017, 12:46pm UTC](https://forum.ansible.com/t/add-option-to-docker-container-module-to-copy-file-into-container-directly/24732/2 "2017-06-15T12:46:45Z")

</div>

You can already do this. The proper solution would be to use the docker connection type and just use the copy module.

[http://docs.ansible.com/ansible/intro\_inventory.html#non-ssh-connection-types](http://docs.ansible.com/ansible/intro_inventory.html#non-ssh-connection-types)

---

<div class="post-metadata">

**Author:** ![Anton\_Bormotov](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Anton\_Bormotov](https://forum.ansible.com/u/Anton_Bormotov)\
**Post date:** [June 16, 2017, 1:52am UTC](https://forum.ansible.com/t/add-option-to-docker-container-module-to-copy-file-into-container-directly/24732/3 "2017-06-16T01:52:21Z")

</div>

Hi Matt,

The docker container is running on the remote host.  
Currently I have 2 tasks:

1. copy file to the remote host;
2. copy file into docker container, using shell task with “docker cp” command.

I have to use ssh connection type in order to connect to the remote host.

I guess, it would be convenient to have an option in docker\_container module to copy file from management host to docker container running on remote host.  
What is your opinion?

---

<div class="post-metadata">

**Author:** ![Bill\_Metangmo](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@Bill\_Metangmo](https://forum.ansible.com/u/Bill_Metangmo)\
**Post date:** [August 4, 2017, 9:02am UTC](https://forum.ansible.com/t/add-option-to-docker-container-module-to-copy-file-into-container-directly/24732/4 "2017-08-04T09:02:00Z")

</div>

I think that you can also already do what you’re explaining . But you have to expose the docker socket as a TCP one , so you can just add you remote docker host as decribed here:  
[http://docs.ansible.com/ansible/latest/intro\_inventory.html#non-ssh-connection-types](http://docs.ansible.com/ansible/latest/intro_inventory.html#non-ssh-connection-types)  
[https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option)
