ITADN

[Feature] Support `DATA_DIR` environment variable to resolve startup failure under `read_only: true`

#1441Closedmoxuanyuan 创建于 2026-06-14
feature
M
moxuanyuancommented
### Description Currently, Doco-CD bind `/data` to a local directory in volumes, for example `/opt/stacks:/data,` attempts to create symlinks or directories at the root filesystem level (e.g., `mkdir /opt` to link to `/opt`) upon startup to handle Docker Socket path translation. However, when the container is deployed with standard security constraints like `read_only: true` (Read-only root filesystem), it crashes with the following error: `failed to create parent directory /opt: mkdir /opt: read-only file system` **Proposal:** Introduce a `DATA_DIR` environment variable that allows users to explicitly define the internal working directory. Instead of hardcoding `/data` and relying on internal symlinks to map to the host path, Doco-CD can use the path specified in `DATA_DIR` as its base operational directory. ### Use Case This feature is critical for users deploying Doco-CD in security-hardened environments where containers must run with a read-only root filesystem. By allowing `DATA_DIR`, users can easily achieve "Strong Path Consistency" (identical internal and external paths), avoiding path translation issues altogether. **Example Configuration:** ```yaml services: doco-cd: image: doco-cd:latest read_only: true environment: - DATA_DIR=/opt/stacks # Define the internal path volumes: - /opt/stacks:/opt/stacks # Internal and external paths are identical - /var/run/docker.sock:/var/run/docker.sock ``` ### Additional Information 1. **Eliminates Dirty Workarounds:** Currently, the only way to bypass this crash is by mounting a `tmpfs` to `/opt`, which is an unintuitive workaround for users simply trying to achieve exact path mapping. 2. **Native Socket Compatibility:** When `DATA_DIR` exactly matches the host's absolute path, Doco-CD can send absolute paths directly to the Docker Daemon via the socket without any need for internal symlink hacks. The Daemon will locate the files perfectly. 3. **Cloud-Native Best Practices:** Handing the authority of the base directory path over to the user via an environment variable is a standard practice adopted by many mainstream containerized tools (e.g., Portainer, Gitea).
关闭于 2026-06-14 2 条评论