To use the existing container isntead of creating one, use docker exec
command instead of docker run
docker exec -it my_devops_toolkit /bin/bash
docker run --rm --network host -it devops-toolkit:latest
# You now in the container terminal
ansible-playbook samples/ansible/check_os.yml
docker run --rm --network host -it devops-toolkit:latest
# You now in the container terminal
# Now run your cloned script
cd ansible-examples
ansible-playbook <YOUR_PLAYBOOK_CMD>
Clone the code to the host then mount to container
# Clone code on the host
docker run --rm -v "$(pwd)":/root/ansible_workspace --network host -it devops-toolkit:latest
# Run the ansible code as usual
- For any issues, check this reference