简体   繁体   中英

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

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

泊坞窗版本

看到错误


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`

如果您没有任何关键数据,您可以删除 docker 卷。

docker volume ls

docker volume rm your_volume

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 .

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

在此处输入图片说明

您可以执行docker volume prune删除所有未使用的本地卷。

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

Check the memory status

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.

If the shared memory is allocated at the NFS mount level, you can verify the usage status with the command

df [OPTION]... [FILE]...

You can allocate more memory to this shared category from the buff/cache which resolved the problem for me

So it is not physical memory space issue but the allocation to shared memory. Simple..!

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM