I have a Docker service (specifically MongoDB). After some kind of failure (specifically No space left on device), it gets weird:
- Command
docker-compose logs --follow --tail=10 -t service-name
exits and writesservice-name exited with code 14
. When I rundocker-compose up service-name
, it attempts to start the container. - However,
docker ps
shows the service running and "Up 2 days". - When the underlying issue is resolved (i.e., some space is freed), the service doesn't restart automatically, although docker-compose.yaml contains
restart: unless-stopped
. It however starts after I tell explicitly Docker to do so (i.e.,docker-compose up some-service
).
Why does this happen? Is there some better solution than just running docker-compose up -d <list of services>
every minute?
Excerpt from docker-compose.yaml:
mongodb:
image: mongo:5
container_name: mongodb
environment:
- PUID=1000
- PGID=1000
ports:
- 127.0.0.1:…:27017
volumes:
- …:/data/db
- "…:/docker-entrypoint-initdb.d/:ro"
restart: unless-stopped
Excerpt from docker ps
:
144a… mongo:5 "docker-entrypoint.s…" 3 days ago Up 5 hours 127.0.0.1:…->27017/tcp mongodb
Failed attempts to start the container:
$ sudo docker-compose up mongodb
Starting mongodb ... error
ERROR: for mongodb Cannot start service mongodb: mkdir /var/lib/docker/overlay2/…/merged: no space left on device
ERROR: for mongodb Cannot start service mongodb: mkdir /var/lib/docker/overlay2/…/merged: no space left on device
ERROR: Encountered errors while bringing up the project.