-
Notifications
You must be signed in to change notification settings - Fork 304
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
Feature request: Allow dynamic "runArgs" for docker #3972
Comments
There is |
If I understood you correctly, you mean to have a self-modifying "linux": {
"runArgsGeneratorCommand": "echo -e '--arg\nvalue'"
} where the generator would then write run args to stdout, each one on a separate line if you don't want to deal with the quotes. Or even better, you could introduce a similar dynamic Currently the whole system is pretty much locked down for any non-static content. Even with |
You could add |
No, that would not work for mounting an extra volume based on user's environment, for example. This information needs to be passed directly to Also, currently there is no clean way for |
You could add that file to |
One of them is for user's customization of the box itself, we use the same for Vagrant and a dev container. We don't use git or dotfiles repository. Another volume is for some optional app-specific data that the user can
mount, if available.
|
You can specify additional mounts with the |
Unfortunately, that's not going to work as we need more complex logic for this than a simple variable replacement. Also, |
What if we added a |
Hmm, I think that approach would be an overly complicated way to pass a few dynamic args to
I believe that just making |
@chrmarti How about something like this? {
"initializeCommand": [ "${localWorkspaceFolder}/generateArgsFile.sh" ],
"linux": { // override
"initializeCommand": "echo -e '--network\nhost' >${localWorkspaceFolder}/.args",
}
// either static or from file
// "runArgs": [ "--arg", "value" ],
"runArgsFile": "${localWorkspaceFolder}/.args",
...
} It's using existing |
@chrmarti Actually, on second thought, I like your idea. However, I'd expect once the container is created for extension to pick it up and run the exact same commands on it like it would normally do. Extension would perform all checks and call this method only if container does not already exist. Also, since Docker does not allow setting of metadata after container creation, there would have to be a way to pass metadata that the extension itself requires for operation to |
Related: #12 (comment) |
Where was this left? I could really use this feature. My specific use case is developing for a USB peripheral in a dev container. Right now my only 2 options are to update the |
+1 Any progress? |
Any news on this feature request? Is something been done? Should It be possible, at least, that VSCode interpolates the environment variables in runArgs before passing the args to docker run? For example, I want to use: "runArgs": [
// GPU support (Direct Rendering Manager)
"--device",
"${DRI_DEVICE:-/dev/null}:/dev/dri"
], that generates:
that ends with error:
as |
I also tried with "runArgs": [
// GPU support (Direct Rendering Manager)
"--device",
"$(echo ${DRI_DEVICE:-/dev/null}):/dev/dri"
], hopping that it is sent directly to the command line but no luck, the '$(echo ${DRI_DEVICE:-/dev/null})' is not evaluated. Looks like this is related to the way the runArgs are passed as the generated command works as expected if manually run: docker run --device $(echo ${DRI_DEVICE:-/dev/null}):/dev/dri ... |
@rubensa You can use |
It is quite annoying to request to devs to comment-uncomment multiple sections every time they need to switch from CPU to GPU: |
I'm looking to dynamically enable a passthrough serial device if its plugged in. Since docker will fail to run if you specify a device that doesnt exist, I need to check if the device first exists, then add the device to the runsArgs if it does. Sounds like this would be required for something like that. In our case, for development a serial device is only needed if dealing with hardware. Might not always have a serial USB plugged in or even need one, so to have to have one plugged in just for the container to boot is not preferred. |
Could you somehow support a way of building and passing dynamic arguments to the docker run command? We currently only have
runArgs
array indevcontainer.json
that is static in nature and not suitable for any sort of scripting. One use case could be, for example, to mount some extra volumes conditionally while keeping all the nice automatic devcontainer infrastructure that the remote extension has to offer. It'd be enough just to include a shell call somewhere. For example, you could introduce a string version ofrunArgs
that would be included verbatim in the default docker run command and then the entire command would be executed by the shell. Or you could introduce arunCommand
override with some pre-defined variables that users would then include in the command they specify. You could also support variables like${workspaceFolder}
inremote.containers.dockerPath
so that we can hack our way through :) ThanksThe text was updated successfully, but these errors were encountered: