[JP] How to configure container log rotation for the Docker daemon

This document (000020051) is provided subject to the disclaimer at the end of this document.

Situation

背景

Dockerのデフォルト設定では、json-fileログドライバーを使用して制限なしでコンテナーログを記録するため、ノードでdisk-fill eventsが発生する可能性があります。この記事では、Dockerを実行しているノードを構成して、コンテナーログサイズを制限し、古いコンテナーログをローテーションする手順について説明します。

事前準備

  • json-fileログドライバーを使用してDockerを実行しているノード
  • /etc/docker/daemon.jsonを編集し、Dockerデーモンを再起動する権限

注意

  • 新しく作成されたコンテナに変更を有効にするには、Dockerデーモンを再起動する必要があります
  • 重要 既存のコンテナのコンテナログ設定は変更なしのため、既存のコンテナは自動的に新しいログ設定を適用されません。新しい設定を使うにはコンテナを再デプロイする必要があります。

解決方法

  1. Dockerデーモンの設定ファイルを編集します:

    $ vim /etc/docker/daemon.json
  2. 次の内容をファイルに追加して、最大コンテナログファイルサイズを10MBに、ローテーションする最多のログファイルを10個に設定します。

    {
      "log-driver": "json-file",
      "log-opts": {
        "max-size": "10m",
        "max-file": "10"
      }
    }
  3. dockerデーモンを再起動して、設定を新しいコンテナーに適用します(上記の重要注意を参照)。

    $ systemctl restart docker

ヒント

このログローテーションの設定をビルド/構成管理システムに導入すると、ノードをプロビジョニング時に自動的に適用され、手動で設定する必要がなくなります。

参考

Docker JSON file log driver documentation

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020051
  • Creation Date: 26-Sep-2022
  • Modified Date:26-Sep-2022
    • SUSE Rancher

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center