Reputation: 359
I know there are many similar questions on this topic. Nothing so far has helped.
Recently I added a new migration file to my Node project and its causing Docker to give the following error during integration tests
- could not create file "base/12379/270766": No space left on device
Specifically, it looks like it's erroring when trying to add a UNIQUE constraint to two columns.
Here's my compose file:
version: '2.1'
services:
web:
build: .
container_name: web_1
env_file:
- ./local.env
environment:
NODE_ENV: development
ECHO_SQL: ${ECHO_SQL}
ports:
- "4000:4000"
And here's the test compose file:
version: '2.1'
services:
web:
env_file:
- ./local.env
environment:
NODE_ENV: test
NO_SERVER: 1
XUNIT_FILE: output/xunit.xml
volumes:
- ./output:/opt/app/output
links:
- "pg"
pg:
image: postgres:9.5
command: postgres -c logging_collector=off -c log_min_error_statement=error -c fsync=off -c full_page_writes=off -c synchronous_commit=off -c archive_mode=off
tmpfs:
- /var/lib/postgresql/data:rw
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: mysecretpassword
And I run the tests with
$ docker-compose -f docker-compose.yml -f docker-compose-test.yml build
$ docker-compose -f docker-compose.yml -f docker-compose-test.yml run web bash -c "./tools/wait-for-pg.sh; grunt"
Disk Space
Other answers have mentioned running out of space on the actual drive. I have a ton of space left on my machine.
Increasing Disk Size
Increased "Disk image size" from 64G to 128G
I then restarted docker desktop. No effect.
Restart
Just in case, I rebooted my laptop after the disk image size change. No effect
Prune
docker system prune --all
Still get the same error.
Deleting The Docker VM File
rm ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
and then restarting Docker Desktop. Still get the same error.
storage_opt
I tried adding storage_opt
to my docker compose file under the pg service.
pg:
image: postgres:9.5
command: postgres -c logging_collector=off -c log_min_error_statement=error -c fsync=off -c full_page_writes=off -c synchronous_commit=off -c archive_mode=off
tmpfs:
- /var/lib/postgresql/data:rw
ports:
- "5432:5432"
storage_opt:
size: '1G'
environment:
POSTGRES_PASSWORD: mysecretpassword
docker-compose gives me this error:
services.pg Additional property storage_opt is not allowed
Not sure what's going on here. I read the spec: https://docs.docker.com/compose/compose-file/compose-file-v2/#storage_opt
Upvotes: 0
Views: 2649
Reputation: 359
I figured it out. The root cause was the use of tmpfs
.
Using tmpfs
for the Postgres data directory drastically speeds up the tests. However, it has a base size of 200mb which is NOT changed by any of the settings listed in any of the other questions.
To increase the size of the tmpfs
change
pg:
image: postgres:9.5
command: postgres -c logging_collector=off -c log_min_error_statement=error -c fsync=off -c full_page_writes=off -c synchronous_commit=off -c archive_mode=off
tmpfs:
- /var/lib/postgresql/data:rw
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: mysecretpassword
to
pg:
image: postgres:9.5
command: postgres -c logging_collector=off -c log_min_error_statement=error -c fsync=off -c full_page_writes=off -c synchronous_commit=off -c archive_mode=off -c log_temp_files=10240
volumes:
- type: tmpfs
target: /var/lib/postgresql/data:rw
tmpfs:
size: 4294967296
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: mysecretpassword
Upvotes: 3