Docker on Debian
Follow these steps to install & update Docker / Compose on a Debian server. Based off the Install Docker Engine on Debian documentation.
Prerequisites
- A fresh machine or server with a modern version of Debian
- SSH access to the machine with
root
or asudo
-capable user account
Fresh Install
For a fresh Docker and Docker Compose install, follow the Install Docker Engine on Debian documentation from Docker.
Post-Install Steps
It is strongly recommended to complete these steps after installation to configure the Linux host machine to interface better with Docker.
Configure json-file logging driver
The default logging driver, json-file
, writes log data to JSON-formatted files on the host filesystem. Over time, these log files expand in size, leading to potential exhaustion of disk resources. We are going to configure this driver to rotate the logs when they grow too large.
- Open (or create) the daemon.json config file:
sudo nano /etc/docker/daemon.json
- Set the log driver to json-file and enable log rotation. Modify the daemon.json file to contain the following:
Add a gist for this code? Not rendering nicely in the steps.
{ "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "3" } }
- Restart Docker for the changes to take effect:
sudo systemctl restart docker