Error Installing Zsh and Zsh-Vcs Packages in Alpine Linux Based Docker Container Using Devcontainer. Json

I am trying to install zsh and zsh-vcs packages in an Alpine Linux based Docker container to use for Dev Container. I have the following commands in my devcontainer.json:

# ...
"onCreateCommand": [
    "apk update",
    "apk add --no-cache zsh-vcs"
],
"features": {
    "": {
         "initStarship": true,
         "plugins": "git zsh-autosuggestions zsh-syntax-highlighting"
    },
    # ...
},
# ...

However, I am encountering an error during the first build attempt. But devcontainer run without any issue at the second attempt.

[95600 ms] Start: Run in container: apk update --no-cache apk add --no-cache zsh-vcs
OCI runtime exec failed: exec failed: unable to start container process: exec: "update --no-cache": executable file not found in $PATH: unknown
[95762 ms] onCreateCommand failed with exit code 126. Skipping any further user-provided commands.
[95766 ms] Error: Command failed: apk update --no-cache apk add --no-cache zsh-vcs
[95767 ms]     at WY (/home/amookhsin/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:235:130)
[95768 ms]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[95768 ms]     at async bl (/home/amookhsin/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:227:4393)
[95768 ms]     at async Ll (/home/amookhsin/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:227:3738)
[95768 ms]     at async vl (/home/amookhsin/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:227:2745)
[95769 ms]     at async EtA (/home/amookhsin/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:613:30249)
[95769 ms]     at async BtA (/home/amookhsin/.vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js:613:27482)
[95784 ms] Exit code 1

What could be causing this issue and how can I ensure that the packages are installed successfully on the first attempt?

Any help or insights would be greatly appreciated. Thank you.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article