Reputation: 19312
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
Reputation: 17261
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"
}
}
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
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
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