The docker client offers the cp sub-command as explained here, which is very handy when one needs to copy a file into a container (note: this is somewhat analogous to Dockerfile ADD instruction in image building). In Docker 1.8 the cp command has been even expanded a bit.
However, reading the Ansible docker module documentation, it appears that this is missing? Here are my 2 questions:
Thanks in advance.
docker (dynamic inventory) Dynamically builds an inventory of all the available containers from a set of one or more Docker hosts. Ansible 2.1. 0 includes major updates to the Docker modules, marking the start of a project to create a complete and integrated set of tools for orchestrating containers.
The docker cp utility copies the contents of SRC_PATH to the DEST_PATH . You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container. If - is specified for either the SRC_PATH or DEST_PATH , you can also stream a tar archive from STDIN or to STDOUT .
Copying Directories from Local to Remote You can also copy folders or directories using the Ansible copy module. If the 'src' path is a directory, then it will be copied recursively. Or the entire directory will be copied. There are two different variations for this task.
By default, the ansible copy module does a force copy to the destination and overwrites the existing file when present.
You can also use the synchronize command ~ examples provided in this link:
http://opensolitude.com/2015/05/26/building-docker-images-with-ansible.html
Using ansible shell
module helped:
- name: copy db dump to localhost
ansible.builtin.shell: docker cp container:/tmp/dump.sql /tmp/dump.sql
cp
option.However from my point of view if you wish to copy something into a container you're probably doing something wrong. Containers should be ephemeral.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With