-
Notifications
You must be signed in to change notification settings - Fork 522
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
How to use vscode-docker as a dependency of other extensions #1496
Comments
@umarcor I'd be interested to know what kind of features you are looking to add. You can define an extension as a required dependency of your extension via the
Given that
Again, as we didn't intend the extension to expose consumable APIs, that logic is not necessarily exposed in a way that can be reused outside of the extension. It'd be great to have more information about the commands you'd like to add to those context menus. If it makes sense, in that those commands are core to the use of Docker for many developers, an option could be to make a contribution to |
@philliphoff, thanks a lot for your very quick reply! Overall, I understand that this is not an expected use case and that sources are not designed to support it. Actually, my main motivation to open this issue was to discuss it.
Sure. I use Docker for Windows very frequently in order to try new projects written in Python, JS/TS, Go, Rust, Ruby... Most of the projects have installation instructions but not ready to use Dockerfiles (or images). Projects have different requirements, so I find myself continuously writing commands such as the following, before attaching VSCode to the containers through 'Remotes - Containers': winpty docker run --rm -it [-v /$(pwd)://src -w //src] [-p 5000] <image_name> [bash]
#or
runx --no-auth -- x11docker --hostdisplay -i [--user=0] -- [-v /$(pwd)://src] [-p 5000] -- <image_name> bash As you see, options are:
Hence, it is not hard (once you learn them by heart) to write these commands, but it is annoying. Plus, having them written in some file does not help much, because I need to find it, copy, modify and them run. It is almost as much effort as writing it all. The feature I'd like to implement is to replace current Of course, current Such a feature is related to #1001, #1321 and it would hopefully fix/close #1274, #1311.
Yes, I assume that maintaining a separate extension will require it to be kept up to date with changes in vscode-docker; and that UX might be bad when non-compatible versions of the extensions are used.
Importing the type definitions is a kind of most-simple use case to reuse some content from this repo. That is, while internal APIs might depend on some specific objects being allocated/available, importing type definitions might be easier. In practice, if I cannot reuse other resources (say functions), I think that this is not critical.
I guess that this was/is the implicit question in this issue: what do you think about enhancing this extension to expose consumable APIs? There are at least two use cases where it'd be so helpful:
It is possible for third-party extensions to import
I agree that this feature might be better contributed to vscode-docker itself, rather than trying to extend it unnaturally. On the one hand, this is because I'm lacking some knowledge about the canonical location of settings and common resources in different contexts: single folder, workspace, user settings, host settings, etc. On the other hand, I think that the use cases that I would like to address are not well supported yet. Unfortunately, I could not build this extension... I tried with
Apart from that, considering how #1001 was handled, I feel that there is no much interest on this feature, as the suggested approach seems to be using either compose files or tasks. Nonetheless, I'd be glad to upstream it. Note that I also considered implementing this as a Task Provider. However, I am not familiar with class |
@umarcor Based on a lot of similar user feedback, we now have a proposal to provide customization of many of the Docker commands issued by the extension. The proposal includes the ability to have multiple customizations, some of which can be automatically matched to specific images/containers and others which can be selected via a prompt. It'd be great to get feedback from you as to how the proposal would meet your needs (or not) that you brought up in this issue (that prompted your original desire to extend our extension). |
@umarcor Have you been able to try out the command customization in 1.0.0? |
@bwateratmsft, unfortunately, I could not. It is in first place of my non-compulsory tasks because I'm using VSCode and Docker every day, and every day I remember it. But I had a trip in the end Feb, then the crisis came and I'm having a hard time to keep up with this. I will let you know as soon as I can. |
No worries! |
@bwateratmsft I wanted to try the new features, but I don't know where to start. I tried adding EDIT Ok. Got it: "docker.commands.runInteractive":
[
{
"label": "mine",
"template": "docker run --rm -it ghdl/ghdl:buster-mcode"
},
{
"label": "yours",
"template": "docker run --rm -it ${tag}"
}
] |
First off, I'd like to say that this new feature is awesome! It is still quite verbose, but it will definitely save lots of typing! It's a great step in the good direction. The following questions are to wrap my head around the current limits and to know about your plans for future releases.
"docker.commands.run":
[
{
"label": "interactive",
"template": "docker run --rm -it ${exposedPorts} ${tag}"
},
{
"label": "daemon",
"template": "docker run --rm -d ${exposedPorts} ${tag}"
}
] I thought that 'Run' might not open a new terminal, while 'Run Interactive' would. That would explain why it is required to tell them apart. However, I found it not to be the case. Both of them do open a new terminal.
{
"label": "customRun",
"template": "docker run --rm -it ${myCustomParam} ${tag}"
}
{
"label": "ghdl",
"template": "docker run --rm -it ${tag}",
"configurations": {
"gmcode": {
"tag": "ghdl/ghdl:buster-mcode"
},
"gllvm": {
"tag": "ghdl/ghdl:buster-llvm-7",
}
}
} In fact, my main use case of these configurations would be with the custom params as asked in the previous point. For example: {
"label": "mount",
"template": "docker run --rm -it ${volume} -w /src ${tag}",
"configurations": {
"src": {
"volume": "$(pwd):/src"
},
"wrk": {
"volume": "$(pwd):/wrk"
},
"abs": {
"volume": "${host}:${container}"
}
}
} Note that the last configuration would be an edge case because it would always prompt the user for "randomID": {
"volume": "/c/Users/username/workdir:/wrk"
} |
Thanks for your interest! I'll try to cover your questions:
"Run" is meant for background container starts (using
No, but we have another bug for that planned for 1.2 (#251). The behavior will be how VSCode treats tasks--if terminal 1 is busy running a different task, then a new terminal will be created, otherwise it will be reused--and so on.
When you are right-clicking, are you doing "Run" or "Run Interactive"? If you set up exactly one "Run Interactive" template, there will never be a prompt for which (more on that below).
We don't have a quickpick/dropdown option for parameters, but we do support arbitrary config values. For example, in settings.json, I could put
I guess it depends what you mean. We have the ability to select through multiple available commands using some contextual hints, with the "docker.commands.runInteractive": {
"label": "My Alpine starter",
"template": "docker run -it ${exposedPorts} ${tag}",
"match": "alpine"
} In this example, Our selection behavior is basically this--if there are matching templates, we ask you to choose which (the choice is automatic if there's exactly 1 matching template--no prompt). If none match, we ask you to choose between all "universal" templates, i.e. those without If you want to get really advanced for a particular image--for example, a database container--and use volumes, specific ports, environment variables, etc.--we'd recommend using the |
That's the default template for each of them. However, now, both of them can be defined as templates of the same command. For example:
Then, 'Run Interactive' feels redundant, because it is already accesible as 'Run'.
When I right-click, it works as expected. However, when I do F1 -> "Docker Images: Run Interactive" instead, the default command is executed. I.e., even if I have three templates, I am not prompted to choose one.
I mean to reduce the verbosity of setting the templates, so that it is possible to have granularity without copying almost identical templates again and again. Conversely, For example, being able to write this:
instead of this:
I'm afraid that |
They can, and that is intentional. You can also make "Run Interactive" do something totally weird like
That sounds like it might be a bug, I'm going to take a look.
What is the task missing that you need? We're certainly open to expanding it if it's lacking. |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
I'm writing a TS extension that provides some features on top of vscode-docker and I would like to use some of the types and functions defined here.
Precisely, a command is added to
"category": "Docker Images"
and to the context menu ("when": "view == dockerImages && viewItem == image", "group": "images_1_run@2"
). This is currently handled as follows:I would like to define the type of
item
asImageTreeItem
instead. The type is defined in subdirsrc/tree/images/ImageTreeItem
of this repo. However, it seems not to be possible to addvscode-docker
as a dependency throughnpm
oryarn
.Apart from that, when the command is executed directly (not from the context menu), the image (
item
) isundefined
. For other commands, vscode-docker shows a list with all the available images so that users can pick one. It is a multi-level menu that asks for the name first, and then shows the tags. I'd like to import and reuse this "menu to select an image" feature. Is it possible?The text was updated successfully, but these errors were encountered: