Is there a maximum size for docker volumes?

Using the postgres:9.3.12 image and a postgres_data docker volume, I attempted to restore a 100GB+ database using pg_restore but ran into a bunch of postgres errors about there being no room left on the device. My hard drive has 400GB free. I’ve been searching everywhere but can’t seem to find any information about the size of the docker VM’s disk. Is there documentation on this? Should there be documentation on it?

1 Like

I’m having the same problem.

In Docker for Mac, the problem is that there’s a maximum size (about 60gb) for this file: ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2. This is where all images, containers, and volumes are stored.
The pg_restore is filling that up.

I don’t know that there’s a fix for this.
There’s this workaround, where you create a replacement Docker.qcow2 file that is allowed to grow larger, but it doesn’t really seem like a good permanent fix: No space left on device error

Here are some relevant links:

You might also be able to work around this by mounting a host directory (e.g. with -v /path/to/some/host/folder:/var/lib/postgresql/data). This would not store your data in a docker volume, which would keep it from increasing the size of that Docker.qcow2 file. This comes with some extremely poor performance, though, which is discussed here.

I’ve also asked how people get around this issue on StackOverflow.

Alas, mounting a host directory did not circumvent the disk space error on my mac docker engine. I also am trying to use a docker container as a postgresql service and attach the data directory as a machine-host volume to bypass the docker size restrictions. Unfortunately, I receive the following error message while trying to use the docker container to restore the data dump into the host-mounted volume:

ERROR: could not extend file "base/16384/18987.2": No space left on device

This is the series of commands I have been running to try to build my docker container:

sudo mkdir -p /var/lib/postgresql/docker_data
sudo cp {/path/to/backup/file} /var/lib/postgresql/docker_data/data.dump
sudo chmod -R 0777 /var/lib/postgresql
docker build --tag postgresql.data.image {/path/to/dockerfile}
docker run --detach --name postgresql.data -v /private/var/lib/postgresql/docker_data:/var/lib/postgresql postgresql.data.image
docker exec -ti postgresql.data bash -c 'pv /var/lib/postgresql/data.dump | pg_restore -vcd {db_name} -U {db_username}'
docker exec -ti postgresql.data bash -c 'service postgresql stop'

It has been two and a half years since the original post. Has no one yet figured out how to attach a host-mounted directory to a docker image in a manner that bypasses docker container size restrictions?

1 Like