# Sharing GPU between Docker containers

**URL:** <https://forums.developer.nvidia.com/t/sharing-gpu-between-docker-containers/354197>\
**Category:** Docker and NVIDIA Docker\
**Created:** [December 10, 2025, 2:24pm UTC](https://forums.developer.nvidia.com/t/sharing-gpu-between-docker-containers/354197 "2025-12-10T14:24:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinashkushwah31](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@avinashkushwah31](https://forums.developer.nvidia.com/u/avinashkushwah31)\
**Post date:** [December 10, 2025, 2:24pm UTC](https://forums.developer.nvidia.com/t/sharing-gpu-between-docker-containers/354197/1 "2025-12-10T14:24:34Z")

</div>

I am running multiple Docker containers using the following command, which exposes **all GPU devices** to each container:

```auto
sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

```

**Scenario:**

- Container **C1** runs **Process P1** , which internally needs to use **GPU IDs 1, 2, 3, and 4**.

- Container **C2** runs **Process P2** at the same time.

Since both containers receive access to **all GPU devices** , I want to understand the expected behavior:

### **Question**

Is it possible that **P2 in C2 also selects GPUs 1, 2, 3, and 4** , leading to **GPU resource contention** , crashes, or failed inference/training runs?

In other words:

- Does Docker or the NVIDIA runtime enforce **per-container GPU isolation** _automatically_?

- Or do I need to explicitly restrict GPU visibility per container (e.g., using `--gpus '"device=0,1"'`)?

- Can GPU resource contention occur if two containers try to use the same GPU simultaneously
