Dockerized Postgres – No space left on device – creating INDEX while PROCESSING TOC

How to solve a Disk full error in Docker Volume using a Postgresql database.

I’m not sure if the issue is with docker, docker volumes or Postgres configuration.

I have 900GB on my hard drive, but that is not how much is in the Docker Image.

I’m not sure if I’m supposed to change configuration with Postgres or if it is a volume size issue.

These are the different errors that I have gotten.

pg_restore: from TOC entry 5728; 1259 21482844 INDEX index_activities_new mydb could not execute query: ERROR:  could not write to file "base/pgsql_tmp/pgsql_tmp173.0.sharedfileset/0.0": No space left on device  creating INDEX "public.index_activities_new" pg_restore: while PROCESSING TOC:   pg_restore: from TOC entry 5729; 1259 10502259 INDEX index_activities_on_activity_for mydb pg_restore: error: could not execute query: ERROR:  could not extend file "base/2765687/3622617": No space left on device HINT:  Check free disk space. 

I have been gradually working through different ways of using pg_restore

# many indexes in the database fail to create pg_restore -h 127.0.0.1 -U postgres -d "mydb" "mydump.dump"  # when running data only, the restore works pg_restore --section=pre-data --section=data -h 127.0.0.1 -U postgres -d "mydb" "mydump.dump"  # when running for specific TOCs, I sometimes have success and sometimes have out of disk space errors pg_restore -v -L x.txt -h 127.0.0.1 -U postgres -d "printspeak_development" "salescrm.dump"  # contents of x.txt ;5971; 1259 31041251 INDEX public index_account_history_data_tenant_source_account_platform_id salescrm ;6138; 1259 2574937 INDEX public index_action_logs_on_action salescrm 

Container shell disk size

docker exec -it pg13 bash  root@51fe1c96f701:/# df -h Filesystem      Size  Used Avail Use% Mounted on overlay          59G   56G   26M 100% / tmpfs            64M     0   64M   0% /dev tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup shm              64M  1.3M   63M   2% /dev/shm /dev/vda1        59G   56G   26M 100% /etc/hosts tmpfs           2.0G     0  2.0G   0% /proc/acpi tmpfs           2.0G     0  2.0G   0% /sys/firmware 

Database that was restored

I have a created a data base and restored a dump from production.

.dump file was 8GB in size and the imported database is 29GB in size

SELECT pg_size_pretty( pg_database_size('mydb_development') );   pg_size_pretty ----------------  29 GB  

Docker Compose

version: '3'  volumes:            pgdata:  services:   pg13:     container_name: "pg13"     image: "postgres:latest"     environment:       POSTGRES_USER: "postgres"       POSTGRES_PASSWORD: "password"      command: "postgres -c max_wal_size=2GB -c log_temp_files=10240 -c work_mem=1GB -c maintenance_work_mem=1GB"      ports:       - "5432:5432"     volumes:       - pgdata:/var/lib/postgresql/data  

From inside the Docker Image