Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore ability to use named volumes #248

Closed
JonathonReinhart opened this issue Mar 19, 2024 · 2 comments · Fixed by #250
Closed

Restore ability to use named volumes #248

JonathonReinhart opened this issue Mar 19, 2024 · 2 comments · Fixed by #250

Comments

@JonathonReinhart
Copy link
Owner

Prior to #227, you could, as a not-officially-support feature map a named volume at a container path:

volumes:
  /foo: foo-volume
$ scuba --root --image debian:8.2 /bin/bash -c "echo yes > /foo/does-it-persist"
$ scuba --root --image debian:8.2 /bin/bash -c "cat /foo/does-it-persist"
yes
$ docker volume ls
DRIVER    VOLUME NAME
local     foo-volume

Since #227, this no longer works.

scuba: Config error: Relative path must start with ./ or ../: foo-volume

Reported #227 (comment) by @haboustak.

@JonathonReinhart
Copy link
Owner Author

JonathonReinhart commented Mar 19, 2024

From #227:

To avoid ambiguity with the old behavior, relative paths must start with ./ or ../.

And the v2.12 docs

To avoid ambiguity, relative paths must start with ./ or ../.

So I think we can easily restore the old behavior, using this required prefix to distinguish the two:

  • If it starts with /, then it is a (host) absolute path.
  • If it starts with ./ or ../, then it is a (host) relative path.
  • Otherwise:
    • If it contains a / it is an error.
    • Otherwise it is a volume name.

NOTE: This only applies to the simple form:

volumes:
  /foo: foo-volume

In the complex form, the key is specifically called hostpath, so we shouldn't use that for a volume name. We should introduce another key -- mutually exclusive with hostpath -- perhaps just name since it is the name of a named volume:

volumes:
  /foo:
    #hostpath: foo-volume    # Error
    name: foo-volume

Test impact:

  • test_volume_as_dict_missing_hostpath

See also:

JonathonReinhart added a commit that referenced this issue Mar 19, 2024
JonathonReinhart added a commit that referenced this issue Mar 22, 2024
Named volumes were unintentionally supported prior to #227. This
restores the prior behavior while remaining unambiguiously compatible
with relative bind-mounts added in #227.

This also adds support for explicit named volumes in complex form
configuration.

Fixes #248
@JonathonReinhart JonathonReinhart added this to the v2.13 milestone Mar 24, 2024
@JonathonReinhart
Copy link
Owner Author

This is released in v2.13.0.

Enjoy your Go module caches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant