The folder /var/lib/docker size increases and can not be reduced

Viewed 17

The folder /var/lib/docker size increases and can not be reduced

The folder /var/lib/docker size increases and can not reduce it, for that i tried to rotate the logs inside this folder by writing the following under each image inside docker-compose.yml file

......
logging:
      driver: "json-file"
      options:
        max-file: 5 
        max-size: 10m 
.....   

 

however the above snippet of the code does not work? is there any way to rotate the logs of the docker

1 Answers

/var/lib/docker contains not only logs but also data for images, volumes, containers, networks etc.
To check which if these is using the space do

docker system df

This space can be reclaimed with docker system prune --volumes which will clean

  - all stopped containers
  - all networks not used by at least one container
  - all volumes not used by at least one container
  - all dangling images
  - all dangling build cache

And will not impact any running containers.

Related