# how to specify log-opt of docker run in ansible to limit the log size of a container?

**URL:** <https://forum.ansible.com/t/how-to-specify-log-opt-of-docker-run-in-ansible-to-limit-the-log-size-of-a-container/26905>\
**Category:** Ansible Project\
**Created:** [March 6, 2018, 12:53am UTC](https://forum.ansible.com/t/how-to-specify-log-opt-of-docker-run-in-ansible-to-limit-the-log-size-of-a-container/26905 "2018-03-06T00:53:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tang\_Ye](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@Tang\_Ye](https://forum.ansible.com/u/Tang_Ye)\
**Post date:** [March 6, 2018, 12:53am UTC](https://forum.ansible.com/t/how-to-specify-log-opt-of-docker-run-in-ansible-to-limit-the-log-size-of-a-container/26905/1 "2018-03-06T00:53:13Z")

</div>

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.

```auto
  - 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 🙂
