I've a simple .devcontainer.json like which uses golang base image, install 3 different tools (kind, kubebuilder, and kubectl). I am using the array syntax in postCreateCommand to install the packages. Here's the file.
However, the postCreateCommand fails to find the curl binary.
[408195 ms] onCreateCommand failed with exit code 126. Skipping any further user-provided commands.
Error: Command failed: curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 chmod +x ./kind mv ./kind /usr/local/bin/kind KUBEBUILDER_LATEST=$(curl -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | grep 'tag_name' | cut -d\" -f4) curl -Lo kubebuilder.tar.gz https://dl.kubebuilder.io/kubebuilder/${KUBEBUILDER_LATEST}/kubebuilder_${KUBEBUILDER_LATEST}_linux_amd64.tar.gz tar -zxvf kubebuilder.tar.gz -C /usr/local/ rm kubebuilder.tar.gz ln -s /usr/local/kubebuilder/bin/kubebuilder /usr/local/bin/kubebuilder KUBECTL_LATEST=$(curl -s https://dl.k8s.io/release/stable.txt) curl -LO https://dl.k8s.io/release/${KUBECTL_LATEST}/bin/linux/amd64/kubectl chmod +x ./kubectl mv ./kubectl /usr/local/bin/kubectl kind version kubebuilder version docker --version go version kubectl version --client apt-get clean
at N7 (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:235:130)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Am (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:4393)
at async Xw (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:3738)
at async $w (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:2745)
at async fa (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:2386)
at async DtA (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:465:1496)
at async NH (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:465:964)
at async KtA (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:482:3771)
at async eB (/home/linuxbrew/.linuxbrew/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:482:4886)
{"outcome":"error","message":"Command failed: curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 chmod +x ./kind mv ./kind /usr/local/bin/kind KUBEBUILDER_LATEST=$(curl -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | grep 'tag_name' | cut -d\\\" -f4) curl -Lo kubebuilder.tar.gz https://dl.kubebuilder.io/kubebuilder/${KUBEBUILDER_LATEST}/kubebuilder_${KUBEBUILDER_LATEST}_linux_amd64.tar.gz tar -zxvf kubebuilder.tar.gz -C /usr/local/ rm kubebuilder.tar.gz ln -s /usr/local/kubebuilder/bin/kubebuilder /usr/local/bin/kubebuilder KUBECTL_LATEST=$(curl -s https://dl.k8s.io/release/stable.txt) curl -LO https://dl.k8s.io/release/${KUBECTL_LATEST}/bin/linux/amd64/kubectl chmod +x ./kubectl mv ./kubectl /usr/local/bin/kubectl kind version kubebuilder version docker --version go version kubectl version --client apt-get clean","description":"The onCreateCommand in the devcontainer.json failed.","containerId":"cef2971520f45f99fc5313bbb8c9b42ad8083b6c5e79d14624091bae9d6c2bcb"}
If I run the same steps inside the devcontainer or pass a shell script, it works just fine. I've gone through the documentation that array syntax doesn't pass the commands to shell, whereas the string format does.
My question is how can I use the array syntax to execute multi line script?
Hi,
I've a simple
.devcontainer.json
like which uses golang base image, install 3 different tools (kind, kubebuilder, and kubectl). I am using the array syntax inpostCreateCommand
to install the packages. Here's the file.However, the
postCreateCommand
fails to find thecurl
binary.If I run the same steps inside the devcontainer or pass a shell script, it works just fine. I've gone through the documentation that array syntax doesn't pass the commands to shell, whereas the string format does.
My question is how can I use the array syntax to execute multi line script?