oznu / docker-unms

This image is no longer maintained: https://github.com/oznu/docker-unms/issues/53
143 stars 68 forks source link

HDD is running full / How to loose data after 14 days ? #12

Closed Snotmann closed 6 years ago

Snotmann commented 6 years ago

Hey guys,

the container and UNMS running fine for me but my disk is running out of space ? How could i save disk space or delete the data after 14 or 28 days ?

Snot

oznu commented 6 years ago

It's probably the logs.

There are two things you can do. The first is to recreate the container with a log rule:

docker run <the rest of your config> --log-driver json-file --log-opt max-size=10m oznu/unms

This will keep the docker log size to less than 10MB.

The second is to clear the UNMS logs:

> /config/unms/logs/unms.log

You can run that command inside the container, or from the host if you replace /config with the path to your mapped volume. You could setup a cron to do this. Alternatively a logrotate policy would work too.

Snotmann commented 6 years ago

Ok I started the container with docker-compose and the yaml file for it. The log was only 300 MB from 5 GB the docker folder was -.-

pi@snotberry:/var/lib $ sudo du -sh /var/lib/docker/ 5.0G /var/lib/docker/

avluis commented 6 years ago

Where are the downloaded firmware images stored? This could be the issue here -- is it possible to define/override the location of fw files?

mevatron commented 6 years ago

I would recommend you run the container with QUIET_MODE = 1 as mentioned in Issue #4.

For example,

docker run -e QUIET_MODE=1 -d oznu/unms

If you need to clear a giant container log, do the following

docker ps -a

You should see something like this:

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                                                                                                                                NAMES
1fd7bcbd5fa4        oznu/unms:latest             "/init"                  17 minutes ago      Up 17 minutes       0.0.0.0:10080->80/tcp, 0.0.0.0:10443->443/tcp

Note the CONTAINER ID, and become root

sudo su

# stop the unms container
docker stop 1fd7bcbd5fa4

Remove the container's json log file

rm /var/lib/docker/containers/1fd7bcbd5fa40f6ae79c403aa73eecc0ad410a52f78fbf92893fb96a944961f6/1fd7bcbd5fa40f6ae79c403aa73eecc0ad410a52f78fbf92893fb96a944961f6-json.log

Restart the container

docker start 1fd7bcbd5fa4

Hope that helps!

petekaik commented 6 years ago

QUIET_MODE=1 solved heavy logging to docker container log but /config/unms/logs/unms.log kept growing rapidly. Let's see if logrotate can keep this file from growing too big. Link logrotate rule file as volume to container in docker-compose.yml like so `volumes:

oznu commented 6 years ago

Thanks @petekaik.

I've added logrotate to the latest build using the config you posted. This should keep the internal log file under control.

petekaik commented 6 years ago

I refreshed my container to your latest image and can see "unms" logrotate rule is now in place. Let's see if that takes care of controlling unms.log size.

petekaik commented 6 years ago

Thanks @petekaik.

I've added logrotate to the latest build using the config you posted. This should keep the internal log file under control.

That 10M rule didn't seem to work afterall. I made another try with "daily" option and check if that cuts it. /config/unms/logs/*.log { daily copytruncate missingok rotate 7 compress delaycompress }

Edit: That didn’t work either. May have to fall back to docker host cron triggering container logrotate.

Update: After few days testing this setup seems to work well enough. Not a 100% clean container solution (not exactly sure what best practice with containers and cron is) but now host crontab triggered container logrotate rotates unms.log and keeps filesizes under control (about 13M of log per day) Host crontab: 58 23 * * * /path/to/your/host/docker exec unms sh -c 'logrotate -f /etc/logrotate.d/unms'

oznu commented 6 years ago

Thanks @petekaik.

Snotmann commented 5 years ago

So its not possible to deactivate the logging into unms.log ?