# Docker 运行配置

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

使用 Docker 运行配置从 CLion 构建 Docker 镜像并运行容器。 例如，您可以运行一个包含应用程序后端使用的数据库的容器。 或者您可以使用应用程序的二进制文件、依赖项及任何其他必要文件来构建映像。 这称为“ dockerizing”一个应用程序。

> **Note:**
> 如果您希望在特定环境中运行或调试应用程序，请创建一个 [Docker run target](run-targets.html#docker) 并配置 [您的应用程序的运行配置](run-debug-configuration.html)，以使用该运行目标而不是您的机器本地环境。

Procedure: 创建 Docker 运行配置

1. 在主菜单中，进入  `运行 | 编辑配置` .

2. 在   运行/调试配置   对话框中，点击 ![“添加新配置”按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)，展开   Docker   组，并选择所需的运行配置类型。

CLion 提供以下几种 Docker 运行配置类型：

Docker 镜像
: 当您 [从现有镜像运行容器](docker-containers.html#run_image)时自动创建。 如需了解更多信息，请参阅 [Docker 映像运行配置](docker-image-run-configuration.html)。

Dockerfile
: 当您 [从 Dockerfile 运行容器](docker-containers.html#run_image_dockerfile)时，自动创建。 如需了解更多信息，请参阅 [Dockerfile 运行配置](dockerfile-run-configuration.html)。

Docker Compose
: 当您从 [Docker Compose 文件](https://docs.docker.com/compose/overview/) [运行一个多容器 Docker 应用程序](docker-compose.html)时自动创建。 如需了解更多信息，请参阅 [Docker compose 运行配置](docker-compose-run-configuration.html)。

## 在另一个运行配置之前运行 Docker 容器

您可以将任何 Docker 运行配置设置为另一个运行配置的 [启动前](run-debug-configurations-dialog.html#before-launch-options)任务。 例如，如果您的应用程序依赖于运行中的数据库，每次从源代码运行应用程序时，您可以自动运行包含数据库的 Docker 容器。

