I want to execute shell commands, for eg: a "wget" command inside a running docker container using Ansible. This is the playbook I am trying to execute
---
- name: Enter into a running container and run a command
docker_container:
name: centos_conatainer
state: started
image: centos
command: wget https://downloadlink.com
This stops the container and also it is not downloading the file. Is this the right way to execute shell commands using docker_container module, or is there any other way to do this using Ansible?
You are looking for the Ansible equivalent of the docker exec command-line.
Command in ansible docker_container is the equivalent of the command option in the docker run command-line.
It doesn't appear that this new Ansible module has support for this. You'll just have to use the generic Ansible command.
Example:
- name: Enter into a running container and run a command
command: docker exec centos_container wget https://downloadlink.com
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