containerd / nerdctl

contaiNERD CTL - Docker-compatible CLI for containerd, with support for Compose, Rootless, eStargz, OCIcrypt, IPFS, ...
Apache License 2.0
8.24k stars 614 forks source link

Add log rotation and log size limits to the nerdctl.toml configuration file #3317

Closed niroshea closed 1 month ago

niroshea commented 3 months ago

What is the problem you're trying to solve

When I run the container with the following command, it works fine.

nerdctl run --log-opt=max-size=100m --log-opt=max-file=5 -d nginx

But I can't specify the --log-opt option when I need to start multiple containers with the nerdctl compose command.

nerdctl compose --log-opt=max-size=100m --log-opt=max-file=5 -f docker-compose.yaml up -d

The error message is as follows: FATA[0000] unknown flag: --log-opt

Is it possible to add options such as log-opt.max-size log-opt.max-file to the nerdctl.toml configuration file so that nerdctl's logging management can take effect globally, avoiding the need to specify parameters on the command line each time?

Describe the solution you'd like

Is it possible to add options such as log-opt.max-size log-opt.max-file to the nerdctl.toml configuration file so that nerdctl's logging management can take effect globally, avoiding the need to specify parameters on the command line each time?

Additional context

No response

yankay commented 2 months ago

niroshea

HI @niroshea

The log can be configured in the compose file like: https://docs.docker.com/reference/compose-file/services/#logging

And the nerdctl needs to keep the compatibility with docker.

niroshea commented 1 month ago

niroshea

HI @niroshea

The log can be configured in the compose file like: https://docs.docker.com/reference/compose-file/services/#logging

And the nerdctl needs to keep the compatibility with docker.

I tried to use this approach with a docker-compose file with the following contents

services:

  ...

  nginx:
    image: nginx
    container_name: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    restart: always
    network_mode: host
    logging:
      driver: json-file
      options:
        max-size: "200m"
        max-file: "3"
    ulimits:
      nproc: 65535
      nofile:
        soft: 32000
        hard: 40000