> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-serverless-sft-revamp.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# wandb docker

Run your code in a docker container.

W\&B docker lets you run your code in a docker image ensuring wandb is configured. It adds the WANDB\_DOCKER and WANDB\_API\_KEY environment variables to your container and mounts the current directory in /app by default. You can pass additional args which will be added to `docker run` before the image name is declared, we'll choose a default image for you if one isn't passed:

```sh theme={null}
wandb docker -v /mnt/dataset:/app/data
wandb docker gcr.io/kubeflow-images-public/tensorflow-1.12.0-notebook-cpu:v0.4.0 --jupyter
wandb docker wandb/deepo:keras-gpu --no-tty --cmd "python train.py --epochs=5"
```

By default, we override the entrypoint to check for the existence of wandb and install it if not present. If you pass the --jupyter flag we will ensure jupyter is installed and start jupyter lab on port 8888. If we detect nvidia-docker on your system we will use the nvidia runtime. If you just want wandb to set environment variable to an existing docker run command, see the wandb docker-run command.

dockerコンテナ 内で コード を実行します。

W\&B docker を使用すると、wandb が設定された状態で docker イメージ内で コード を実行できます。このコマンドは、`WANDB_DOCKER` と `WANDB_API_KEY` の 環境変数 をコンテナに追加し、デフォルトで現在の ディレクトリー を `/app` にマウントします。イメージ名が指定される前に `docker run` に追加される引数を渡すことができます。イメージが指定されない場合は、デフォルトのイメージが自動的に選択されます。

```sh theme={null}
# データセットのディレクトリをマウントして実行
wandb docker -v /mnt/dataset:/app/data

# 特定のイメージとJupyterを指定して実行
wandb docker gcr.io/kubeflow-images-public/tensorflow-1.12.0-notebook-cpu:v0.4.0 --jupyter

# 特定のイメージ、TTYなし、特定のコマンドを指定して実行
wandb docker wandb/deepo:keras-gpu --no-tty --cmd "python train.py --epochs=5"
```

デフォルトでは、エントリーポイントを上書きして wandb の存在を確認し、存在しない場合はインストールします。`--jupyter` フラグを渡すと、jupyter がインストールされていることを確認し、ポート 8888 で jupyter lab を起動します。システムで nvidia-docker が検出された場合は、nvidia ランタイムを使用します。既存の `docker run` コマンドに wandb の 環境変数 を設定したいだけの場合は、`wandb docker-run` コマンド を参照してください。

## Usage（使い方）

```bash theme={null}
wandb docker [DOCKER_RUN_ARGS] [DOCKER_IMAGE] [OPTIONS]
```

## Arguments（引数）

| 引数                | 説明   | 必須  |
| :---------------- | :--- | :-- |
| `DOCKER_RUN_ARGS` | 説明なし | いいえ |
| `DOCKER_IMAGE`    | 説明なし | いいえ |

## Options（オプション）

| オプション       | 説明                                                                         |
| :---------- | :------------------------------------------------------------------------- |
| `--nvidia`  | nvidia ランタイムを使用します。nvidia-docker が存在する場合はデフォルトで nvidia になります（デフォルト: False） |
| `--digest`  | イメージのダイジェストを出力して終了します（デフォルト: False）                                        |
| `--jupyter` | コンテナ内で jupyter lab を実行します（デフォルト: False）                                    |
| `--dir`     | コンテナ内のどの ディレクトリー に コード をマウントするかを指定します（デフォルト: /app）                         |
| `--no-dir`  | 現在の ディレクトリー をマウントしません（デフォルト: False）                                        |
| `--shell`   | コンテナを起動するシェルを指定します（デフォルト: /bin/bash）                                       |
| `--port`    | jupyter をバインドするホストポートを指定します（デフォルト: 8888）                                   |
| `--cmd`     | コンテナ内で実行する コマンド                                                            |
| `--no-tty`  | tty なしで コマンド を実行します（デフォルト: False）                                          |
