I am currently having this issue:
Command failed: /bin/sh -c ./.devcontainer/postCreateCommand.sh
which is the
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
setting from the devcontainer.json.
But the script works when I deactivate the "postCreateCommand" and run it manually after container creation. Which made me think, that the issue might be the path to the script somehow. But that is not the case either. Since an empty script with just an echo command seems to work.
The script is the following:
echo "Installing Developer Requirements"
apt-get update && apt-get install -y man git
pip3 install -r .devcontainer/dev_pip_requirements.txt
Any ideas how to debug the "PostCreateCommand"? The output is less than helpful and I don't want to start reducing this project into a minimum working example.
I changed git to checkout everything with linux file endings on windows. And I triple checked that the shell script has LF endings. So those should not be an issue either. (They were previously).
I think that one cause may be that the user does not have enough permissions to even execute the apt-get update command.
Changing the remoteUser to root, in the devcontainer.json configuration file should allow to execute the postCreateCommand.sh shell script successfully when running it using bash.
I've tried it using the python:3.8-slim-buster Docker image, having set a non-root user in the Dockerfile.
I've added the following to the ./.devcontainer/devcontainer.json:
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",
"remoteUser": "root",
I've used the following ./.devcontainer/postCreateCommand.sh:
#!/usr/bin/env bash
set -ex
apt-get update && apt-get install -y man git && rm -rf /var/lib/apt/lists/*
pip install --requirement ./.devcontainer/dev_pip_requirements.txt
Generally, root is not recommended for production environments.
Here is a little more information about postCreateCommand
https://github.com/microsoft/vscode-remote-release/issues/1685#issuecomment-542950190
https://github.com/microsoft/vscode-remote-release/issues/1685#issuecomment-543895263
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With