Docker FATAL: could not write lock file "postmaster.pid": No space left on device
Asked Answered
C

7

28

postgres:9.5

I try rebooting,

docker-compose build --no-cache

delete image and container and build again

I have many proyects and anybody starts, keeps the same configuration... Mac osx Sierra

docker version

see the error


Apparently the containers were not deleted well, I tried with this and after rebuild works ok.

# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)

docker-compose.yml

version: '2'
services:
  web:
    build: .
    image: imagename
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - "3000:3000"
      - "8000:8000"
    volumes:
      - .:/code
    depends_on:
      - migration
      - redis
      - db
  redis:
    image: redis:3.2.3
  db:
    image: postgres:9.5
    volumes:
      - .:/tmp/data/
  npm:
    image: imagename
    command: npm install
    volumes:
      - .:/code
  migration:
    image: imagename
    command: python manage.py migrate --noinput
    volumes:
      - .:/code
    depends_on:
      - db

Dockerfile:

FROM python:3.5.2
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/

RUN mkdir /code
WORKDIR /code

RUN easy_install -U pip

ADD requirements.txt /code/requirements.txt
RUN pip install -r requirements.txt`
Celiotomy answered 11/4, 2017 at 19:36 Comment(6)
It sounds like the volume is in read-only mode. Can you add the docker-compose.yml contents and any other script that set up this environment?Mady
sure, here is nowCeliotomy
Is there definitely space on the drive that /tmp/data is mounted on? (And does the user the Docker dameon is running as have perms to write to it?)Deandre
What directory are you running your docker-compose command from, are you in /user, /User (case matters), /projects, etc?Sevenfold
Why do you need to set the /tmp/data/ volume for? By analyzing the Dockerfile for Postgres:9.5 link you'll see that is defining a managed volume /var/lib/postgresql/data. NOTE: Volume .:/tmp/data/ means that you declare a Bind Mount Volume - mapping a location on host to one on the container vs. a Managed Volume. This might require to set also USER mapping.Mady
It seems that there were some "No space left on device" problems in Docker for Mac. You can try to isolate and create a docker-compose file only with the postgres:9.5 in it and see if it starts. If does not then maybe there is a bug and one needs to be submitted on this link. Check also if this does the trick for you - rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2Mady
S
19

If you do not have any critical data you can blow away the docker volume.

docker volume ls

docker volume rm your_volume

Spineless answered 28/11, 2017 at 17:20 Comment(0)
R
29

You can do docker volume prune to remove all unused local volumes.

Representationalism answered 17/7, 2020 at 23:32 Comment(0)
S
26

If you're coming here from Google and finding that multiple containers are complaining of Disk space, the issue may be that your local Docker installation has maxed out its disk image size. This is configurable in Docker for Mac. Here are the instructions to change that disk image size.

Schach answered 6/3, 2020 at 21:48 Comment(1)
This is really helpful. I used up 88GB and allowed 120GB, but still got this error. After deleting some unused volumes and images, and increased allowed space, it is back to normal.Inhuman
F
24

My case, goto docker Dashboard -> Settings and increate Disk Image size then restart

enter image description here

Feaze answered 17/2, 2021 at 4:2 Comment(0)
S
19

If you do not have any critical data you can blow away the docker volume.

docker volume ls

docker volume rm your_volume

Spineless answered 28/11, 2017 at 17:20 Comment(0)
I
3

If you're facing issues about disk space from a single or multiple containers in your Docker for Mac development environment, there are two possible solutions you can consider.

Firstly, the issue may be related to the disk image size limitation of your local Docker installation. Cleaning up some unused images might solve the issue.

$ docker volume prune

This command frees up disk space by deleting volumes that are no longer in use.

If this approach didn't work, try changing the Docker for Mac - Disk image size settings.

Modifying the settings should be considered as a last resort if the volume pruning does not solve the problem. This approach ensures that you optimize the disk space efficiently without making unnecessary changes to Docker for Mac's configuration.

Impish answered 7/7, 2023 at 3:54 Comment(0)
F
1

Off late, I faced a similar issue with postgres and mysql databases. All of a sudden these containers exited without any external trigger. I spend much time on this issue finally it was identified as RAM allocation issue in the server.

There were 13 containers working in the same path out of which 3 postgres and 1 mysql database containers also present. These containers exited and the application stopped working. There were 2 errors in the docker logs - mainly postgresql database directory appears to contain a database and FATAL: could not write lock file "postmaster.pid": No space left on device

I tried stopping all other services and starting the database containers only but this issue repeated

First of all check the storage utilisation status with the below command

df [OPTION]... [FILE]...
df -hP

In my case, it was showing 98% utilised and databases were not able to add new records which caused the problem. After allocated additional memory to the NFS mount, the issue cleared

Once it is done, verify the RAM utilisation status also which will be increased now

free -h

This will return values in total, used, free, shared, buff/cache, available. If you try stopping containers one by one and restarting, you can see these are consuming memory from the shared category. So in my case, there was almost 18M showing initially in shared which was not enough for the databases to run along with all other containers. After the NFS mount is increased, the shared RAM also increased to 50M which means all services working fine

So it is pure physical storage space issue and you should act proactively to remove old unused files, docker images which takes huge space, local docker volumes etc. Check in docker documentation to perform these steps

https://docs.docker.com/config/pruning/

Flagg answered 20/7, 2022 at 7:26 Comment(0)
B
0

I faced this problem on Docker Desktop for Mac, after I've rebuilt the containers and started these via docker compose up. But the older versions of these containers were already running, because these were set to restart automatically.

I.e. the PostgreSQL DB couldn't set the lock on the named volume, because there was a concurrent access with the running container.

Bruckner answered 5/12, 2022 at 15:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.