How to add customized build options with devcontainer cli?

51 Views Asked by At

For some reason I have to add the following options to the docker build command when running devcontainer up:

--add-host=host.docker.internal:host-gateway --build-arg HTTPS_PROXY=http://host.docker.internal:1080

I find from this doc that I can use build.args to specific build-arg and here is my configuration

{
  "image": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu",
  "build": {
    "args": {
      "http_proxy": "http://172.17.0.1:1080",
      "https_proxy": "http://172.17.0.1:1080"
    }
  },
  "appPort": 8080,
  "features": {
    "ghcr.dockerproxy.com/devcontainers/features/go:1": {
      "version": "1.21"
    },
    "ghcr.dockerproxy.com/devcontainers/features/node:1": {
      "version": "20"
    },
    "ghcr.dockerproxy.com/devcontainers/features/docker-in-docker:2": {},
    "ghcr.dockerproxy.com/devcontainers/features/python:1": {}
  },
  "forwardPorts": [9000, 9090, 2746, 8080],
  "hostRequirements": {
    "cpus": 4
  },
  "runArgs": [
    "--add-host=host.docker.internal:host-gateway",
    "--add-host=dex:127.0.0.1",
    "--add-host=minio:127.0.0.1",
    "--add-host=postgres:127.0.0.1",
    "--add-host=mysql:127.0.0.1",
    "--add-host=azurite:127.0.0.1"
  ],
  "postCreateCommand": ".devcontainer/pre-build.sh",
  "workspaceMount": "source=${localWorkspaceFolder},target=/home/vscode/go/src/github.com/argoproj/argo-workflows,type=bind",
  "workspaceFolder": "/home/vscode/go/src/github.com/argoproj/argo-workflows",
  "remoteEnv": {
    "PATH": "${containerEnv:PATH}:/home/vscode/go/bin",
    "GOPATH": "/home/vscode/go"
  }
}

But the actual command running is

 docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-chenglab/container-features/0.56.1-1707032528485 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/vscode/devcontainers/base:ubuntu --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-argo-workflows-main-786eedc0416670a1d14a7d9eff7e152b3e6c365adf4daac9c51d4fc9614302e7-features -f /tmp/devcontainercli-chenglab/container-features/0.56.1-1707032528485/Dockerfile.extended /tmp/devcontainercli-chenglab/empty-folder

It seems doesn't take effect. Is there any suggestion for solving this issue?

0

There are 0 best solutions below