pkaramol
pkaramol

Reputation: 19312

docker: configure logging options

According to the official docker documentation, to configure logging options (such as max log file size), one should tweak the /etc/docker/daemon.json file.

However, the only file in my system under /etc/docker is key.json.

How can I set / get the max file size for logging? (per container or system-wide?)

docker: 17.09.1-ce

os: Ubuntu 16.04.03

on aws ec2 t2.small instance

Upvotes: 0

Views: 698

Answers (2)

Bernard
Bernard

Reputation: 17261

  1. Create a new daemon.json file using this:

cat << EOF > /etc/docker/daemon.json { "dns": ["8.8.8.8", "8.8.4.4"], "tls": true, "tlsverify": true, "tlscacert": "/etc/docker/ca.pem", "tlscert": "/etc/docker/server-cert.pem", "tlskey": "/etc/docker/server-key.pem", "log-opts": { "max-size": "10m", "max-file": "2" } }

  1. Reference it in the init script for dockerd

mkdir -p /etc/systemd/system/docker.service.d cat << EOF > /etc/systemd/system/docker.service.d/custom.conf [Service] ExecStart= ExecStart=/usr/bin/dockerd -H fd:// -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2376 --config-file /etc/docker/daemon.json EOF

  1. Restart your docker daemon

sudo systemctl daemon-reload sudo systemctl restart docker

This assumes that you're using TLS to access dockerd remotely (strongly recommended). I suspect that you're not since your /etc/docker dir doesn't have any cert and keys. In that case, remove all tls entries in daemon.json and replace tcp://0.0.0.0:2376 by tcp://0.0.0.0:2375.

Upvotes: 1

yamenk
yamenk

Reputation: 51738

The /etc/docker/daemon.json doesn't exist by default. You can create it and configure the logging options. Make sure to restart the docker service afterwards.

systemctl restart docker.service

Upvotes: 1

Related Questions