> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/fr/blog/how-to-fine-tune-llms-with-unsloth-and-docker.md).

# Comment fine-tuner des LLM avec Unsloth et Docker

Découvrez comment fine-tuner des LLM ou faire de l'apprentissage par renforcement (RL) avec l'image Docker d'Unsloth.

L'entraînement local peut être complexe en raison de l’enfer des dépendances ou d’environnements cassés. L’image Docker d’Unsloth [Image Docker](https://hub.docker.com/r/unsloth/unsloth) peut contourner ces problèmes. Aucune configuration n’est nécessaire : récupérez l’image, lancez-la et commencez l’entraînement.

* **Image Docker officielle d’Unsloth :** [**`unsloth/unsloth`**](https://hub.docker.com/r/unsloth/unsloth)

**Pourquoi utiliser Unsloth et Docker ?**

L’image Docker d’Unsloth est stable, à jour et fonctionne dans [les environnements pris en charge](/docs/fr/commencer/fine-tuning-for-beginners/unsloth-requirements.md#system-requirements) comme Windows.

* Des dépendances entièrement contenues gardent votre système propre. S’exécute en toute sécurité sans root.
* Utilisez-le localement ou sur n’importe quelle plateforme avec des notebooks préinstallés.

{% hint style="success" %}
Vous pouvez désormais utiliser notre image Docker principale `unsloth/unsloth` pour les GPU Blackwell et de la série 50 - aucune image distincte n’est nécessaire.
{% endhint %}

### ⚡ Tutoriel étape par étape

{% stepper %}
{% step %}
**Installez Docker et le NVIDIA Container Toolkit.**

Installez Docker via [Linux](https://docs.docker.com/engine/install/) ou [Desktop](https://docs.docker.com/desktop/) (autre).\
Puis installez [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation):

<pre class="language-bash"><code class="lang-bash"><strong>export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.17.8-1
</strong>sudo apt-get update &#x26;&#x26; sudo apt-get install -y \
  nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
  nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
  libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
  libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}
</code></pre>

<figure><img src="https://550366147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-41cae231ed4761f844ce9836e03b17aabd7c803c%2Fnvidia%20toolkit.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Lancez le conteneur.**

[**`unsloth/unsloth`**](https://hub.docker.com/r/unsloth/unsloth) est la seule image Docker d’Unsloth. Pour [Blackwell](/docs/fr/blog/fine-tuning-llms-with-blackwell-rtx-50-series-and-unsloth.md) les GPU de la série 50, utilisez cette même image - aucune image distincte n’est nécessaire. Si vous utilisez DGX Spark, vous devrez suivre notre [guide DGX](/docs/fr/blog/fine-tuning-llms-with-nvidia-dgx-spark-and-unsloth.md).

```bash
docker run -d -e JUPYTER_PASSWORD="mypassword" \
  -p 8888:8888 -p 2222:22 \
  -v $(pwd)/work:/workspace/work \
  --gpus all \
  unsloth/unsloth
```

<figure><img src="https://550366147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-2b50d78c5d54eaf189c0a40d46c405585ea23082%2Fdocker%20run.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Accédez à Jupyter Lab**

Accédez à [http://localhost:8888](http://localhost:8888/) et ouvrez Unsloth.

<figure><img src="https://550366147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-828df0a668fd94025c1193c24a7f09c1d58dcbd8%2Fjupyter.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Accédez aux `onglets unsloth-notebooks` pour voir les notebooks Unsloth.

<div><figure><img src="https://550366147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-e7a3f620a3ec5bff335632ff9b0cb422f76528a1%2FScreenshot_from_2025-09-30_21-38-15.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://550366147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-531882c33eb96dec24e2d7673471d6a3928a3951%2FScreenshot_from_2025-09-30_21-39-41.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Commencez l’entraînement avec Unsloth**

Si vous débutez, suivez notre guide [de fine-tuning](/docs/fr/commencer/fine-tuning-llms-guide.md), [Guide RL](/docs/fr/commencer/reinforcement-learning-rl-guide.md) ou enregistrez/copiez simplement l’un de nos [notebooks](/docs/fr/commencer/unsloth-notebooks.md).

<figure><img src="https://550366147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fgit-blob-665f900b008991ddcd8fdabb773b292de3c41e72%2FScreenshot_from_2025-09-30_21-40-29.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

#### 📂 Structure du conteneur

* `/workspace/work/` — Votre répertoire de travail monté
* `/workspace/unsloth-notebooks/` — Exemples de notebooks de fine-tuning
* `/home/unsloth/` — Répertoire personnel de l’utilisateur

### 📖 Exemple d’utilisation

#### Exemple complet

```bash
docker run -d -e JUPYTER_PORT=8000 \
  -e JUPYTER_PASSWORD="mypassword" \
  -e "SSH_KEY=$(cat ~/.ssh/container_key.pub)" \
  -e USER_PASSWORD="unsloth2024" \
  -p 8000:8000 -p 2222:22 \
  -v $(pwd)/work:/workspace/work \
  --gpus all \
  unsloth/unsloth
```

#### Configuration de la clé SSH

Si vous n’avez pas de paire de clés SSH :

```bash
# Générer une nouvelle paire de clés
ssh-keygen -t rsa -b 4096 -f ~/.ssh/container_key

# Utiliser la clé publique dans docker run
-e "SSH_KEY=$(cat ~/.ssh/container_key.pub)"

# Connexion via SSH
ssh -i ~/.ssh/container_key -p 2222 unsloth@localhost
```

### ⚙️ Paramètres avancés

| Variable           | Description                                      | Par défaut |
| ------------------ | ------------------------------------------------ | ---------- |
| `JUPYTER_PASSWORD` | Mot de passe de Jupyter Lab                      | `unsloth`  |
| `JUPYTER_PORT`     | Port de Jupyter Lab à l’intérieur du conteneur   | `8888`     |
| `SSH_KEY`          | Clé publique SSH pour l’authentification         | `Aucun`    |
| `USER_PASSWORD`    | Mot de passe pour `unsloth` l’utilisateur (sudo) | `unsloth`  |

```bash
-p <port_hôte>:<port_conteneur>
```

* Jupyter Lab : `-p 8000:8888`
* Accès SSH : `-p 2222:22`

{% hint style="warning" %}
**Important**: Utilisez des montages de volumes pour conserver votre travail entre les exécutions du conteneur.
{% endhint %}

```bash
-v <dossier_local>:<dossier_conteneur>
```

```bash
docker run -d -e JUPYTER_PORT=8000 \
  -e JUPYTER_PASSWORD="mypassword" \
  -e "SSH_KEY=$(cat ~/.ssh/container_key.pub)" \
  -e USER_PASSWORD="unsloth2024" \
  -p 8000:8000 -p 2222:22 \
  -v $(pwd)/work:/workspace/work \
  --gpus all \
  unsloth/unsloth
```

### **🔒 Notes de sécurité**

* Le conteneur s’exécute par défaut en tant qu’utilisateur non root `unsloth` par défaut
* Utilisez `USER_PASSWORD` pour les opérations sudo à l’intérieur du conteneur
* L’accès SSH nécessite une authentification par clé publique


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/fr/blog/how-to-fine-tune-llms-with-unsloth-and-docker.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
