Skip to content

Resolve relative host paths in volume mount specs#11

Merged
ryanmoran merged 1 commit intomainfrom
relative-mount
Mar 17, 2026
Merged

Resolve relative host paths in volume mount specs#11
ryanmoran merged 1 commit intomainfrom
relative-mount

Conversation

@ryanmoran
Copy link
Owner

What

Volume mount specs that use relative host paths (starting with .) are now resolved to absolute paths based on the working directory when contagent is invoked.

Key changes:

  • Add resolveVolumePaths function in internal/config.go that expands ./relative/path host paths to absolute paths using startDir
  • Named volumes (e.g., myvolume:/container/path) and container-only specs are left unchanged
  • Add tests covering relative paths, relative paths with options (:ro), and named volumes
  • Add .agents/ to .gitignore

Why

Docker volume mount specs require absolute host paths. When users run contagent from a project directory and pass --volume ./data:/app/data, Docker would fail because the relative path isn't valid. This change makes relative volume paths work intuitively, resolving them against the directory from which contagent is invoked.

How to Test

Steps:

  1. Run the test suite: go test ./...
  2. Build: go build -o contagent .
  3. Try a relative volume mount: ./contagent --volume ./some-dir:/container/dir some-command
  4. Verify the container receives an absolute path for the volume

Expected behavior:

  • ./relative/path:/container/path becomes /absolute/path/relative/path:/container/path
  • Named volumes like myvolume:/container/path remain unchanged
  • Tests pass including the three new volume path resolution cases

Resolves relative host paths in --volume specs to absolute paths
based on the invoking working directory.
@ryanmoran ryanmoran merged commit 0cee50b into main Mar 17, 2026
1 check passed
@ryanmoran ryanmoran deleted the relative-mount branch March 17, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant