Run Command Inside of Docker Container Using Ansible

前端 未结 5 718
情话喂你
情话喂你 2020-12-07 16:48

what I\'m trying to accomplish is to run commands inside of a Docker container that has already been created on a Digital Ocean Ubuntu/Docker Droplet using Ansible.

5条回答
  •  無奈伤痛
    2020-12-07 17:08

    You should be able to execute a script (with your sequence of command in it) with docker exec:

    docker exec container-name bash -l -c /path/to/script > /path/to/log
    

    (See also "Why do I have to use bash -l -c inside my container?")

    • /path/to/script should be accessible by your Ansible process.
    • /path/to/log is a path inside the container, that could be shared in a volume.

提交回复
热议问题