My initial conditions were a little different yet I think the solution still applies here.
I was creating a .devcontainer
with a docker-in-docker
and nvidia-cuda
features enabled. I could see the GPU in the dev container but it wasn't available to the container on the second level. For that, I needed to install nvidia-container-toolkit
in the first level container.
Since nvidia-container-toolkit
creates a new docker runtime, this requires a dockerd
restart. Default instructions would achieve this via sudo systemctl docker restart
command, however, due to space constraints, sometimes systemctl
isn't available.
Like the OP, I also resorted to restarting dockerd
by killing the process and starting it again.
In short, I've achieved this by adding the following line to my CUDA-enabled devcontainer.json
:
// Reload dockerd after installing the nvidia-container-toolkit.
"postCreateCommand": "sudo pkill dockerd && sudo pkill containerd && bash /usr/local/share/docker-init.sh",
Commands sudo pkill dockerd
and sudo pkill containerd
essentially terminate dockerd
and containerd
processes. /usr/local/share/docker-init.sh
script was brought-in by ghcr.io/devcontainers/features/docker-in-docker
feature, so, if you're using it, you don't need to modify the command.
However, if not, you should replace bash /usr/local/share/docker-init.sh
with ( dockerd > /tmp/dockerd.log 2>&1 ) &
to start dockerd
process again.
dockerd
process. For things running in containers, you don't usually restart processes but rather delete and recreate the container; can you delete the DinD container? – Ambrosio