βοΈ Shared Config
Shared Docker Compose AnchorsΒΆ
The following shared anchors are used across services in your docker-compose.yml file to ensure consistent configuration for logging, labeling, and resource limits.
Standardized Logging for Docker services
The following shared anchors are used across services in your docker-compose.yml file to ensure consistent configuration for logging, labeling, and resource limits.
- β Uses Grafana Loki for log aggregation
- β Dynamic URL using environment variable
- β Maximum 5 retries on failure
- β 400 log lines per batch maximum
- β 2 second wait for partial batches
- β 10 second request timeout
- β 5 seconds maximum between retries
- β 1 second minimum between retries
- β Default tenant identifier
Remember
- The
SYNOLOGY_BASIC_URL
must be set in your environment or replaced with your direct Loki URL - These settings can be adjusted as needed, but the shown values are recommended by Loki docs for:
- Balanced performance (batch size 400)
- Reliable delivery (retries 5)
- Network resilience (timeout 10s)
- For production environments, consider:
- Increasing batch size if high log volume
- Adjusting timeouts based on network latency
Standardized labels for Docker services
The following shared anchors ensure consistent behavior across your docker-compose.yml
:
- β Enables Watchtower to auto-update this container
- β Custom marker for deployment-triggered recreation
- β Categorizes containers (e.g.,
proxy
,db
,monitoring
)
Standardized Resource Limits for Docker services
The following shared anchors ensure consistent behavior across your docker-compose.yml
:
- β Container won't exceed 50% of a CPU core
- β Hard memory cap of 512MB (OOM kill if exceeded)
- β Guaranteed 25% of a CPU core
- β Always allocated 256MB memory buffer
Example UsageΒΆ
Here's how to implement these shared anchors in a service definition: