basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    A missing volume path makes Docker create an empty directory

    If the host path doesn’t exist, the short volume syntax creates an empty root-owned directory in its place. When removing a stack, also remove its paths from neighbours’ volumes — or use the long syntax: in this situation it fails with an error.

    What it looks like

    You removed /opt/traefik, but CrowdSec still has a volume on its logs:

    volumes:
      - /opt/traefik/data/logs:/opt/traefik/data/logs:ro

    The next time CrowdSec is recreated, /opt/traefik/data/logs appears again, empty. CrowdSec starts and watches logs that no longer exist.

    The long syntax fails in the same situation, and the missing path shows right away:

    volumes:
      - type: bind
        source: /opt/traefik/data/logs
        target: /opt/traefik/data/logs
        read_only: true

    If it doesn’t work

    Removed a stack, and its directory came back — empty and owned by root

    Cause
    A neighbouring stack still has a volume on the removed one’s path. The short syntax recreates the path when the container is recreated.
    Fix
    Remove that volume from the neighbour. To make a missing path visible right away, use the long syntax (type: bind).

    How to check

    Before removing a stack, look for its path in the neighbours’ compose files:

    grep -rn '/opt/traefik' /opt/*/docker-compose*.y*ml