You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Running containers in development is straightforward. Running them reliably in production requires careful attention to logging, health checks, restart policies, resource management, and orchestration. This lesson covers the patterns and tools that make containers production-ready.
Docker supports multiple logging drivers. The default is json-file, which stores logs as JSON on the host.
| Driver | Description |
|---|---|
json-file | Default; logs stored as JSON files on host |
syslog | Sends logs to a syslog server |
journald | Sends logs to systemd journal |
fluentd | Sends logs to Fluentd |
awslogs | Sends logs to AWS CloudWatch |
gcplogs | Sends logs to Google Cloud Logging |
none | Disables logging |
# Use the json-file driver with rotation
docker run -d \
--log-driver json-file \
--log-opt max-size=10m \
--log-opt max-file=3 \
my-app:latest
# Send logs to syslog
docker run -d \
--log-driver syslog \
--log-opt syslog-address=tcp://logserver:514 \
my-app:latest
services:
api:
image: my-api:latest
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.