0

I have a devcontainer.json which contains the following in

{
  "name": "Dev Container",
  "dockerComposeFile": [
    "docker-compose.yaml"
  ],
  "workspaceFolder": "/workspace",
  "service": "dev",
  "postStartCommand": [
    ".devcontainer/setup/run-at-start.sh"
  ],
  "remoteUser": "ci"
}

where run-at-start.sh contains:

url=https://www.server.com
# git config --global "credential.$url.useHttpPath" true
git config --global --unset-all credential.$url.helper || true
git config --global --add "credential.$url.helper" ""
git config --global --add "credential.$url.helper" "cache --socket=$HOME/.cache/git/credential/socket0"

# This starts the daemon.
echo
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path="
    echo "username=banana"
    echo "password=general"
} | git credential approve

printf "protocol=https\nhost=www.server.com\n" | git credential fill

the postStartCommand. The container starts up and I see the credentials popping out on the credentials from git credential fill but after the postStartCommand has finished and I log into the container with

devcontainer exec --workspace-folder . bash

I dont see any git-credential-cache daemon running. It seems it has already exited...

I am not sure, but when I log into the container and run the same script and logout and back into it again with docker exec ... bash, the credential manager is still running and the git credential fill prints the credentials which where approved...

Somehow it does not stay running when devcontainer runs postStartCommand. The container user is ci and the daemon runs as ci as I see from ps.

How can I make this happen? I tried to play around setsid and disown etc...

Gabriel
  • 8,990
  • 6
  • 57
  • 101

0 Answers0