Run Command Inside of Docker Container Using Ansible

前端 未结 5 724
情话喂你
情话喂你 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:21

    You can run commands within docker containers using the command module For example this code will execute echo "Hello1" and echo "Hello2" in my_container:

       tasks:
            - name: Execute commands in docker container
              command: docker exec -it my_container bash -c 'echo "Hello1"; echo "Hello2"'
    

提交回复
热议问题