Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix 'No space left on device' error in Docker?

Tags:

docker

I'm running a Mac-native Docker (no virtualbox/docker-machine).

I have a huge image with a lot of infrastructure in it (Postgres, etc.). I have run cleanup scripts to get rid of a lot of cruft--unused images and so forth.

When I run my image I get an error like:

could not create directory "/var/lib/postgresql/data/pg_xlog": No space left on device 

On my host Mac /var is sitting at 60% space available and generally my disk has lots of storage free.

Is this some Docker configuration I need to bump up to give it more resources?

Relevant lines from mount inside docker:

none on / type aufs (rw,relatime,si=5b19fc7476f7db86,dio,dirperm1) /dev/vda1 on /data type ext4 (rw,relatime,data=ordered) /dev/vda1 on /etc/resolv.conf type ext4 (rw,relatime,data=ordered) /dev/vda1 on /etc/hostname type ext4 (rw,relatime,data=ordered) /dev/vda1 on /etc/hosts type ext4 (rw,relatime,data=ordered) /dev/vda1 on /var/lib/postgresql/data type ext4 (rw,relatime,data=ordered) 

Here’s df:

[11:14]   Filesystem     1K-blocks    Used Available Use% Mounted on none           202054928 4333016 187269304   3% / tmpfs            1022788       0   1022788   0% /dev tmpfs            1022788       0   1022788   0% /sys/fs/cgroup /dev/vda1      202054928 4333016 187269304   3% /data shm                65536       4     65532   1% /dev/shm tmpfs             204560     284    204276   1% /run/docker.sock 
like image 925
Greg Avatar asked Dec 19 '16 17:12

Greg


People also ask

How do I free up space on my docker?

A stopped container's writable layers still take up disk space. To clean this up, you can use the docker container prune command. By default, you are prompted to continue. To bypass the prompt, use the -f or --force flag.

What happens when docker runs out of memory?

If a container is using an unexpected amount of either type of memory, it runs out of memory without affecting other containers or the host machine. Within this setting, if the kernel memory limit is lower than the user memory limit, running out of kernel memory causes the container to experience an OOM error.

How do you add a space to a docker volume?

eventually this guide helped me to resize/expand my docker volume. 2 - Shut down your VM, open VM Settings > Hard Disk(s) > change size of your 'virtual_disk. vmdk' (or whatever is your machine's virtual disk), then click Apply (see this guide).


2 Answers

I haven't found many options for this, the main issue in github is https://github.com/docker/for-mac/issues/371

Some of the options suggested there are:

  • If you can remove all images/containers, you can follow these instructions:

docker rm $(docker ps -a -q) docker rmi $(docker images -q) docker volume rm $(docker volume ls |awk '{print $2}') rm -rf ~/Library/Containers/com.docker.docker/Data/*

  • You can try to prune all unused images/containers but this has proven not very effective:

docker system prune

  • Use a template image that is larger, install qemu using homebrew and move the image around, see this specific comment: https://github.com/docker/for-mac/issues/371#issuecomment-242047368 but you need to have at least 2x of space left to do this without losing containers/images.

See also: How do you get around the size limitation of Docker.qcow2 in the Docker for Mac? And https://forums.docker.com/t/no-space-left-on-device-error/10894/26

like image 187
pcambra Avatar answered Oct 04 '22 09:10

pcambra


I ran into the same issue, running docker system prune --volumes resolved the problem.

"Volumes are not pruned by default, and you must specify the --volumes flag for docker system prune to prune volumes."

See: https://docs.docker.com/config/pruning/#prune-everything

like image 25
Khateeb321 Avatar answered Oct 04 '22 08:10

Khateeb321