Docker磁盘空间问题留在主机上

我有PostgreSQL在Docker容器中运行(OS X 10.11.6上的Docker 17.09.0-ce-mac35),我从主机上的Python应用程序插入数据。 经过一段时间,我始终在Python中获得以下错误,而主机上仍有大量可用的磁盘空间:

psycopg2.OperationalError: could not extend file "base/16385/24599.49": wrote only 4096 of 8192 bytes at block 6543502 HINT: Check free disk space. 

这是我docker-compose.yml

 version: "2" services: rabbitmq: container_name: rabbitmq build: ../messaging/ ports: - "4369:4369" - "5672:5672" - "25672:25672" - "15672:15672" - "5671:5671" database: container_name: database build: ../database/ ports: - "5432:5432" 

数据库Dockerfile看起来像这样:

 FROM ubuntu:17.04 RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main" > /etc/apt/sources.list.d/pgdg.list RUN apt-get update && apt-get install -y --allow-unauthenticated python-software-properties software-properties-common postgresql-10 postgresql-client-10 postgresql-contrib-10 USER postgres RUN /etc/init.d/postgresql start &&\ psql --command "CREATE USER ****** WITH SUPERUSER PASSWORD '******';" &&\ createdb -O ****** ****** RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/10/main/pg_hba.conf RUN echo "listen_addresses='*'" >> /etc/postgresql/10/main/postgresql.conf EXPOSE 5432 VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] CMD ["/usr/lib/postgresql/10/bin/postgres", "-D", "/var/lib/postgresql/10/main", "-c", "config_file=/etc/postgresql/10/main/postgresql.conf"] 

df -k输出:

 Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk2 1088358016 414085004 674017012 39% 103585249 168504253 38% / devfs 190 190 0 100% 658 0 100% /dev map -hosts 0 0 0 100% 0 0 100% /net map auto_home 0 0 0 100% 0 0 100% /home 

更新1:

看来容器现在已经closures了。 我将重新开始并在容器closures之前尝试df -k

 2017-11-14 14:48:25.117 UTC [18] HINT: In a moment you should be able to reconnect to the database and repeat your command. 2017-11-14 14:48:25.120 UTC [17] WARNING: terminating connection because of crash of another server process 2017-11-14 14:48:25.120 UTC [17] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory. 2017-11-14 14:48:25.120 UTC [17] HINT: In a moment you should be able to reconnect to the database and repeat your command. 2017-11-14 14:48:25.132 UTC [1] LOG: all server processes terminated; reinitializing 2017-11-14 14:48:25.175 UTC [1] FATAL: could not access status of transaction 0 2017-11-14 14:48:25.175 UTC [1] DETAIL: Could not write to file "pg_notify/0000" at offset 0: No space left on device. 2017-11-14 14:48:25.181 UTC [1] LOG: database system is shut down 

更新2:

这是容器上的df -k/dev/vda2似乎快速填满了:

 $ docker exec -it database df -k Filesystem 1K-blocks Used Available Use% Mounted on none 61890340 15022448 43700968 26% / tmpfs 65536 0 65536 0% /dev tmpfs 1023516 0 1023516 0% /sys/fs/cgroup /dev/vda2 61890340 15022448 43700968 26% /etc/postgresql shm 65536 8 65528 1% /dev/shm tmpfs 1023516 0 1023516 0% /sys/firmware 

更新3:

这似乎与Docker.qcow2上约64 GB的文件大小限制有关。 使用qemu和gparted解决如下:

 cd ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/ qemu-img info Docker.qcow2 qemu-img resize Docker.qcow2 +200G qemu-img info Docker.qcow2 qemu-system-x86_64 -drive file=Docker.qcow2 -m 512 -cdrom ~/Downloads/gparted-live-0.30.0-1-i686.iso -boot d -device usb-mouse -usb