Docker containers high disk usage

Viewed 420

I'm running some docker images using docker-compose on a virtual machine. When I start these containers, they use about 55MB:

# docker system df

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          11        7         6.038GB   1.891GB (31%)
Containers      14        14        55.83MB   0B (0%)
Local Volumes   32        4         27.25MB   27.2MB (99%)
Build Cache     0         0         0B        0B

after about a week, I get some warning about low disk space on virtual machines and I found that those containers consuming about 122GB of disk space!

# docker system df

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          11        7         6.038GB   1.891GB (31%)
Containers      18        0         122.2GB   122.2GB (100%)
Local Volumes   28        6         27.2MB    9.633MB (35%)
Build Cache     0         0         0B        0B

I face this problem many times till I found that and use docker container prune to remove them.

I use a local path for volumes in docker-compose and point that path to some disk that is on a different partition than root(/). here is a sample of my docker-compose:

version: '3'

services:
  webapp:
    image: my-image
    restart: always
    logging:
      options:
        max-size: "8m"
        max-file: "4"
    environment:
      TZ: Asia/Tehran
    volumes:
      - ./volumes/data:/var/webapp/data:Z
    ports:
      - 127.0.0.1:8080:8080
    depends_on:
      - db

 db:
    image: postgres:11
    restart: always
    environment:
      POSTGRES_DB: database_name
      POSTGRES_USER: database_user
      POSTGRES_PASSWORD: database_password
      TZ: 'Asia/Tehran'
      PGTZ: 'Asia/Tehran'
    volumes:
      - ./volumes/db/:/var/lib/postgresql/data:Z

0 Answers
Related