I am trying to setup a DevContainer for Dapr to make dev environment setup easy. I would like to run Dapr Init automatically so that there are no manual steps needed to run services.
I put "dapr init" in the postStartCommand, but when it runs it says there is no Docker Runtime available.
❌ could not connect to docker. docker may not be installed or running
Immediately after that fails, I can manually run "dapr init" in a terminal and it works appropriately.
I have tried giving it more time by adding a "sleep 30", but that doesn't seem to help.
Is there anything I can do to ensure the docker runtime is up and running so I can automatically initialize dapr?
Here is my devcontainer definition
{
"name": "Dapr Quickstarts Codespace",
"dockerFile": "Dockerfile",
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"ms-azuretools.vscode-dapr",
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-dotnettools.csdevkit"
]
}
},
"features": {
"ghcr.io/dapr/cli/dapr-cli:0": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"mounts": [
// Mount docker-in-docker library volume
"source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"
],
"postStartCommand": "dapr init",
// Always run image-defined docker-init.sh to enable docker-in-docker
"overrideCommand": false,
"remoteUser": "codespace",
"runArgs": [
// Enable ptrace-based debugging for Go in container
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
// Enable docker-in-docker configuration
"--init",
"--privileged"
]
}