-
Notifications
You must be signed in to change notification settings - Fork 293
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
Allow additional build flags when building a container #3545
Comments
Any word on when this might get added? We work in Amazon Workspaces Linux instances and in order to build/run Docker images/containers you need to pass I can work around this by building the container outside vscode and then open my devcontainer project in vscode. I then use the "runArgs": ["--network=host"]. This is less than optimal. We are trying to make this a standard for projects we support but without this it is difficult. |
In my case I would like to use |
For some cases (such as mine), the following workaround can be useful: // pre build image to leverage --cache-from
"initializeCommand": [
"docker",
"build",
"--target=devcontainer",
"--cache-from=armdocker.rnd.ericsson.se/proj-river/cicd-devcontainer",
"."
], This will build the image the way I want, and later when VS Code tries to build it, it will be already cached and will be almost instantaneous. |
Hello, Regards |
Another very important use-case I don't see mentioned above is that this feature is needed in order to use docker "build --ssh=default". This is used to allow the host ssh-agent to sign for build commands (such as pulling from a private github repository using ssh). |
And since I have the docker buildx plugin I cannot run it since I have to pass |
|
I am using this emulator (https://github.com/tonistiigi/binfmt), does that makes |
Yes |
Yes, this has been blocking me for years. |
I am in Japan and the When building from Remote-Containers, this technique cannot be used and builds take a long time... |
I'm not sure if this was said here or not, but Remote Containers supports docker-compose. It means you can leverage whatever docker-compose let you do in the build. Even if it's for a single container. |
Was curious if theres been any progress on this? I'm basically unable to use the built-in .devcontainer system due to not being able to pass the --ssh default flag on build. Something like a
would be incredibly helpful. |
Thanks! "initializeCommand": [
"docker", "build", "--network=host", ".devcontainer"
], worked for me. |
Wondering if @Chuxel, @bamurtaugh or if @chrmarti would have an update on this? The feature is quite useful indeed. Anyone building images that require cloning from private repositories would be really well served with this option. Also, does someone has a working workaround to use ssh agent based authentication when building a container image based on devcontainer.json ? I don't immediately understand what @Trass3r is doing. |
As of today, using the pre-release version of the plugin (don't know if available on the release version), "build": {
"args": {
"BUILD_ARG1": "value1",
"BUILD_ARG2": "value2"
}
}, |
@LudovicTOURMAN I've just retested using Remote - Containers v0.241.1 Pre-Release version. My devcontainer.json looks like:
The container creation fails, see log below:
The offending part is I was expecting something on the lines of: Which actually works fine for me when the container creation is launched directly from the WSLs command line. Any hints ? |
It looks amazing that 53 upvotes of this issue in 2 years changed nothing. Even when there is a myriad of problems that it could potentially solve 😔. It looks there was a time when this feature worked. 👉 Any update on this? |
For the people who used "initializeCommand": ["docker", "build", "--ssh=default", "-f", ".devcontainer/Dockerfile", "."] workaround doesn't work for me. Note, I'm agent forwarding with |
As this is something that is missing in the dev-container specification itself, I started a feature discussion regarding this there: devcontainers/spec#301 |
Sometimes it is necessary to pass secrets to the dev container build. While I learned that we can use something like ${localEnv:VAR1}, which is great, it is not sufficient from my point of view. Is it possible to ask the user for a specific argument, such as:
*) Ask the user if the value should be stored in a local login store (optional second version). Use case: While this is a specific use case, it can also apply to many other use cases where secrets should only be stored in a secure repository. |
For years I have been using docker compose instead. You can do that too, no? |
For anyone having this trouble I would suggest to use a post-install script called after the build command that allows for user authentication inside docker. 👌 that's how we "workarounded" the issue and works like a charm. |
I added a proposal devcontainers/spec#328 and also the spec change devcontainers/spec#324 |
@felipecrs Thanks but it's the 3rd time you mention this. This feature should exist without needing to use Docker Compose. |
Yes, for sure. I'm not denying that. I was just trying to provide an alternate solution so that users don't need to wait on this to be implemented. |
The proposal devcontainers/spec#328 is merged. 👍 In progress: devcontainers/cli#85 and devcontainers/spec#324. |
Available in Dev Containers 0.333.0-pre-release. |
This is great being able to specify build arguments now! Is there a way the user can specify those build arguments (or a script can be run on the host machine)? I'm thinking something like this.
Using "${inputs:XX}" works in VSCode launch.json however it looks like it isn't support for .devcontainers.json. |
@aidan-gallagher Correct, that is not supported at the moment. Seeing your feature request for this at #9397. Thanks. |
@aidan-gallagher +1, would love to see this implemented. |
Awesome, thanks! Is it possible @chrmarti to also include Docker's official buildx bake tool as well? that would allow passing in a larger build spec file (instead of lots of cli flags) |
I just tried it with the pre-release of 0.333.0 with the following build:
but I don't see this added to the |
@Roemer That should indeed work. Could you open an issue with the log from rebuilding the container? Thanks! @c-ameron That is not supported by the feature implemented here. devcontainers/spec#311 is a good place to track it. Thanks! |
|
@pmunin Could you open an issue with the log included? ( |
@chrmarti as i mentioned in that other comment - I discovered after reloading the window that my installed prerelease version was not 0.337, but 0.330 instead which is max available for standard vscode build: So seems like I need VS Code Insider to try it, which I'm not ready to install yet, hope it's ok. But I cannot wait this feature to be released. This |
The current pre-release versions of the Dev Containers extension also adopt changes from the upcoming VS Code 1.86 which is why they require VS Code Insiders at the moment. VS Code 1.86 is expected to release some time next week at which point we will also release a new stable version of the Dev Containers extension. |
When building a devcontainer from dockerfile it will be useful to expose out additional
docker build
args that can be used when the container is created.This can be done either by direct linking of these commands to the
build
property in the.devcontainer.json
or via a catch-all array likebuild.command_flags: ["--network=host", "--compress"]
etcExample, a dockerfile is installing packages from an internal repository but your machine is on a vpn. Would need to pass
--network=host
to the build command to ensure that traversal happens correctly on Linux hosts.The text was updated successfully, but these errors were encountered: