Safeguard
Developer Tools•

How to enable GPUs in Docker with the NVIDIA toolkit, safely

Install steps for the NVIDIA Container Toolkit with Docker, what each command changes, and review points that keep a GPU host from becoming a soft target.

Safeguard Security Team
3 min read

Install the NVIDIA driver, add NVIDIA's package repository, install the container toolkit packages, then run the toolkit command that configures the Docker runtime and restart Docker. Each step changes the host, so pin versions, review the configuration diff, and record what you installed.

The steps, in order

Based on NVIDIA's install guide:

  1. Install the GPU driver, preferably through your distribution's package manager, as the guide recommends.
  2. Add NVIDIA's production repository for your package manager. Experimental packages are optional, and a production host does not need them.
  3. Install the four packages: nvidia-container-toolkit, nvidia-container-toolkit-base, libnvidia-container-tools and libnvidia-container1, all pinned to the same version.
  4. Configure Docker:
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

The first command updates /etc/docker/daemon.json. The restart makes Docker read it.

What to check at each step

StepWhat to review
RepositoryUse the vendor documented repository for your package manager
PackagesPin all four to one version so they cannot drift apart
ConfigureLook at the change before you apply it
RestartPlan it, because it restarts the container runtime

The guide notes that the nvidia-ctk config command prints its changes to standard output unless you pass the in place or output options. It advises reviewing previews before production updates, especially when you use a specific config file. That preview step is a cheap control, so use it.

Variants worth knowing

Other container engines are supported: containerd, CRI-O and Podman. For Podman, NVIDIA recommends the Container Device Interface for device access. Rootless Docker needs extra steps, including setting the no cgroups option in the toolkit configuration, so do not copy the rootful commands blindly.

The guide also lists a known cgroup issue: on systems using the systemd cgroup driver, containers can lose access to the GPUs after a daemon reload. That is a reliability point, but it explains why teams are tempted to loosen settings to make things work. Fix the cause rather than adding privileged mode.

Habits that keep the host tidy

Try it yourself

Click through it at your own pace, or open it full screen. Watch how packages inside an image are listed and checked.

Safeguard can scan container images and dependencies, and its free scan lives at gold.safeguard.sh/scan.

Quick check

Do I need the toolkit just to run a CPU container?

No. The toolkit is for exposing NVIDIA GPUs to containers. Hosts without GPUs do not need it.

Is it fine to copy the rootful commands for rootless Docker?

No. The guide lists different commands and an extra configuration option for rootless setups.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.