I am using ansible playbook to deploy my app with docker in Jenkins, Recently I want to limit the log size of the app container, with “docker run” has “–log-opt max-size=xxxm” option, but How can I add the same function in ansible playbook?
I tried to set ansible playbook as below, but the test shows it not works.
- name: start container
docker_container:
name: "{{docker_container}}"
image: "{{docker_image}}"
log_options:
max-size: 256m
max-file: 2
volumes:
- "/etc/timezone:/etc/timezone"
- "/etc/localtime:/etc/localtime"
published_ports:
- "{{published_ports}}"
recreate: yes
The location of log file of container which I want to limit the size is as the file below:
/var/lib/docker/containers/2fdcae9fb35f4954639a3ff254873f0ae8518f2ede011807/2fdcae9fb35f4954639a3ff254873f0ae8518f2ede0118072304077918deb20f-json.log
Thanks for your reply first