Add option to docker_container module to copy file into container directly

3,258 views
Skip to first unread message

Anton Bormotov

unread,
Jun 15, 2017, 4:05:07 AM6/15/17
to Ansible Development
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,

Matt Martz

unread,
Jun 15, 2017, 8:47:03 AM6/15/17
to Ansible Development, Anton Bormotov
You can already do this. The proper solution would be to use the docker connection type and just use the copy module.



--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Matt Martz
@sivel
sivel.net

Anton Bormotov

unread,
Jun 15, 2017, 9:52:21 PM6/15/17
to Ansible Development, qqw...@gmail.com
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?

Bill Metangmo

unread,
Aug 4, 2017, 5:02:00 AM8/4/17
to Ansible Development, qqw...@gmail.com
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
https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
Reply all
Reply to author
Forward
0 new messages