docker-in-docker: Add an onCreateCommand
to wait for Docker to be ready
#710
+45
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my devcontainer, which runs as an unprivileged user, Docker was not running properly after the script started up. Editing the script to output more debug info (to make
docker info
not be quiet) showed it was outputting:Further adding a
groups
call showed that the user was not in thedocker
group when we tried to calldocker info
. This made it always fail when run from the install script. The retry loop ran the maximum number of times, and we were left with severaldefunct
(zombie) docker and containerd processes.Moving the checking to an
onCreateCommand
fixes this, as this runs fully as the user. Furthermore, this makes the user's commands, and the container's startup, block on Docker being available. This is beneficial, as it means that there won't be a time when you can use the dev container but Docker isn't there.We do still keep the retrying logic, and we signal between the
onCreateCommand
and the install script by creating a flag file.