Support for Docker Volumes in Development Containers #15915
|
Per this comment, and the devcontainers documentation, development containers do not yet support Docker volumes. I use a Docker volume for my renv cache so that packages don't have to be reinstalled when I rebuild my container. A Docker volume makes more sense to me than a normal mount in this case because the cache contains linux specific package binaries that I would never need on my local Mac. For this use case, support for Docker volumes would be a useful feature for me. I'm also open to suggestions for a better place to store my renv cache. |
Replies: 1 comment 1 reply
|
Thanks for that clear description of your renv cache use case! The good news is that the "Docker volumes are not supported" limitation is narrower than you might be interpreting it. It refers to configurations where the workspace itself lives in a named volume (VS Code's "clone repository in container volume" style setups), not to volume mounts you declare yourself. Positron passes the {
"image": "rocker/r-ver:4.5",
"mounts": [
"source=renv-cache,target=/renv-cache,type=volume"
],
"containerEnv": {
"RENV_PATHS_CACHE": "/renv-cache"
}
}The named volume persists across container rebuilds, so your Linux package binaries stay cached without ever touching your Mac's filesystem. A few notes on this:
Can you give that named volume mount approach a try? If you run into any problems, please let us know. |
Thanks for that clear description of your renv cache use case!
The good news is that the "Docker volumes are not supported" limitation is narrower than you might be interpreting it. It refers to configurations where the workspace itself lives in a named volume (VS Code's "clone repository in container volume" style setups), not to volume mounts you declare yourself. Positron passes the
mountsentries from yourdevcontainer.jsonstraight through todocker create, includingtype=volume, so this should already work today:{ "image": "rocker/r-ver:4.5", "mounts": [ "source=renv-cache,target=/renv-cache,type=volume" ], "containerEnv": { "RENV_PATHS_CACHE": "/renv-cache" } }T…