====== 23 Docker log設定 ======
===== ログの場所 =====
# ls -alh /var/lib/docker/containers/*/*-json.log
# docker inspect app-proxy-1 | grep -i log
"LogPath": "/var/lib/docker/containers/415a09895929c250e05f2ec463c2affc144166884a93b1591e8cd2a884b86a7a/415a09895929c250e05f2ec463c2affc144166884a93b1591e8cd2a884b86a7a-json.log",
"LogConfig": {
===== 1.ログを消す =====
# truncate -s 0 /var/lib/docker/containers/415a09895929c250e05f2ec463c2affc144166884a93b1591e8cd2a884b86a7a/415a09895929c250e05f2ec463c2affc144166884a93b1591e8cd2a884b86a7a-json.log
===== 2. docker-compose.ymlで設定 =====
services:
app:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
===== 3. Dockerの設定ファイル =====
{
"log-driver": "json-file",
"log-opts": {"max-size": "10m", "max-file": "3"}
}
{{tag>Docker}}