Skip to content
New issue

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

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

Already on GitHub? # to your account

Adding an additional build option via options is not added to the docker buildx command #9417

Closed
Roemer opened this issue Jan 22, 2024 · 9 comments
Assignees
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster

Comments

@Roemer
Copy link

Roemer commented Jan 22, 2024

As requested in #3545 (comment), I create this issue as something seems not to work correctly with the additional build options.

When adding eg. --add-host, this option is not added to the build command and therefore the host is not available.

  • VSCode Version: 1.85.2
  • Local OS Version: Windows 10
  • Remote OS Version: WSL2 Debian
  • Remote Extension/Connection Type: Containers in WSL
  • Logs:
    The build command looks like:
    Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-roemer/container-features/0.55.0-1705941702893/Dockerfile-with-features -t vsc-tmp_feature-75968010dd2d4d01cc001523df80afe29b3349da87789eac4fabc7f9c36c120c --target dev_containers_target_stage --no-cache --pull --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/roemer/projects/tmp_feature/.devcontainer

Steps to Reproduce:

  1. Create a devcontainer specification and add a build option like:
"build": {
      "dockerfile": "Dockerfile",
      "options": [
        "--add-host=host.docker.internal:host-gateway"
      ]
    },
  1. Build the container and check the log, no build command contains this additional option

Does this issue occur when you try this locally?: -
Does this issue occur when you try this locally and all extensions are disabled?: -

@vscodenpa vscodenpa added the containers Issue in vscode-remote containers label Jan 22, 2024
@chrmarti
Copy link
Contributor

Could you retry with VS Code Insiders (http://code.visualstudio.com/insiders/) and the latest Dev Containers pre-release (currently 0.335.0)? The latest Dev Containers pre-release doesn't support VS Code 1.85. Alternatively you could wait for VS Code 1.86 and a new Dev Containers stable release to come out (expected next week).

@chrmarti chrmarti self-assigned this Jan 24, 2024
@chrmarti chrmarti added the info-needed Issue requires more information from poster label Jan 24, 2024
@pmunin
Copy link

pmunin commented Jan 26, 2024

just tried switching to pre-release - right after switching it shows 0.337, but after reloading window or restarting vscode it shows 0.330. And build options does not work in that version (whatever is installed), options just ignored

@chrmarti
Copy link
Contributor

@pmunin You get 0.330.0 when you are installing in VS Code 1.85. Please try with VS Code Insiders (make sure you update it to the latest version): http://code.visualstudio.com/insiders/

@pmunin
Copy link

pmunin commented Jan 26, 2024

Thanks for clarification @chrmarti (and sorry for missing your older comment where you already explained that) - as I mentioned in another issue - unfortunately I cannot afford installing vscode insider on my work environment, I'll just wait till it becomes available in stable vscode build and monitor this thread

@Nummer42O
Copy link

Can confirm, it works in VS Code 1.86.0 and Dev Containers v0.338.0. At least my --ssh default option went through. 👍

@pmunin
Copy link

pmunin commented Feb 1, 2024

Made it work only after doing it via multiline:

    "options": [
      "--ssh",
      "default"
    ]

will fail if you do it in one line:

    "options": [
      "--ssh default"
    ]

That was confusing, but glad that it worked somehow.


The more serious issue that build.options is ignored for the case of dockerComposeFile:[...]. Why it was decided to make dockerComposeFile separated from build:{...} options? 🤦

UPDATE:
Docker-compose ssh, actually can be specified at the docker-compose.yml: https://docs.docker.com/compose/compose-file/build/#ssh (all that time of waiting for this feature we could have just workaround it with docker-compose.yml?? 🤦 🤦 🤦 )
However I still think would be more intuitive to have it in build/dockerComposeFile, as there most probably will be other usecases to have options for dockercompose build:

Start: Run: docker-compose --project-name <PROJECT> -f /path/to/project/.devcontainer/docker-compose.yml -f /var/folders/s5/tcdx_v214l78cv7pdttlnr7c0000gn/T/devcontainercli/docker-compose/docker-compose.devcontainer.build-1706797919504.yml build <PROJECT> <...build.options?>

@Roemer
Copy link
Author

Roemer commented Feb 1, 2024

I can also confirm that it now works with VSCode 1.86.0 and Dev Containers extension v0.338.1. Many thanks for that.
Edit: And it also works when adding features, the options are also added there so finally, features can be used without the need of a compose file.

@chrmarti
Copy link
Contributor

chrmarti commented Feb 2, 2024

@pmunin The individual arguments need to be listed as separate strings, these can be on a single line. E.g., the following would also work:

    "options": [ "--ssh", "default" ]

This may seem technical, but it avoids the need for any parsing to separate the arguments later (e.g., like a shell would do, but we spawn the build command without using a shell).

When using Docker Compose we are avoiding duplicating options available in the docker-compose.yml to keep the devcontainer.json simple.

@vscodenpa
Copy link

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!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2024
@microsoft microsoft locked and limited conversation to collaborators Mar 25, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants