дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
The Welcome screen lists local dev container configurations and an open devcontainer.json offers Open in Container, both through the existing Reopen in Container flow with trust and host checks; the reopen prompt remembers dismissal per project. Fixes #7417
116 рядки
7.7 KiB
Plaintext
116 рядки
7.7 KiB
Plaintext
---
|
||
title: "Containers"
|
||
description: "Reopen a local project in its dev container, and run configurations in Docker or Docker Compose containers."
|
||
---
|
||
|
||
OpenIDEA works with containers in two ways:
|
||
|
||
- **Dev containers**: the whole project opens inside the container described by its `devcontainer.json`, with the IDE
|
||
backend running there. This is remote development, like [SSH](/en/guide/remote/ssh).
|
||
- **Docker and Docker Compose run targets**: the project stays local and only a run configuration runs in a
|
||
container.
|
||
|
||
To list, start, stop and inspect containers, images and Compose services, use the [Services](/en/guide/services)
|
||
tool window.
|
||
|
||
## Dev containers
|
||
|
||
### Requirements
|
||
|
||
- Docker installed on your machine, with the daemon of the current Docker context running locally. The project folder
|
||
is bind-mounted into the container, so a daemon on another machine doesn't work.
|
||
- The Dev Containers CLI (`devcontainer`). Install **Dev Containers CLI** from
|
||
**Settings › Languages & Frameworks › Language Servers** (it needs Node.js), or put `devcontainer` on your `PATH`.
|
||
- A `.devcontainer/devcontainer.json`, `.devcontainer.json`, or `.devcontainer/<name>/devcontainer.json` in the project folder.
|
||
- The project must be trusted: building the container runs the project's commands (`initializeCommand`, the
|
||
Dockerfile build).
|
||
- A Linux container on x86_64 or aarch64.
|
||
|
||
### Open a project in its container
|
||
|
||
- From the Welcome screen, select **Remote Development › Dev Container** and choose the project folder. If the
|
||
folder has several configurations, select the one to use. Click **Open** and trust the folder if prompted.
|
||
- From a local project, use the **Reopen in Container** action in the editor banner for the configuration you want
|
||
to use. You can also choose **File › Reopen in Container** to use the default configuration.
|
||
- When you open a trusted local project with a dev container configuration, the IDE offers **Reopen in Container**.
|
||
Choose **Don't ask again** to hide the notification for that project.
|
||
|
||
OpenIDEA runs `devcontainer up` to build or start the container, then installs and starts
|
||
[`openidea-server`](/en/guide/remote/server) inside it. The first build can take a while.
|
||
|
||
The project then opens at the container's `remoteWorkspaceFolder`, as its `remoteUser`. The status bar shows
|
||
**Dev Container: `<folder name>`**, and the project appears in the recent projects list on the Welcome screen.
|
||
|
||
The Welcome dialog shows connection errors inline. In a local project, **Reopen in Container** reports failures in
|
||
a notification. The message includes the end of the CLI's log when available.
|
||
|
||
### What applies from `devcontainer.json`
|
||
|
||
- Everything `devcontainer up` handles: image, Dockerfile, features, mounts and the lifecycle commands. They run once,
|
||
through the CLI; the server doesn't run `postStartCommand` again.
|
||
- `remoteEnv`: applied to terminals, runs, language servers and tools in the container. Change it and choose
|
||
**File › Reload Environment** to apply it to new processes.
|
||
- `forwardPorts`: forwarded to your machine automatically. Forward more in the **Ports** tool window, as in an
|
||
[SSH window](/en/guide/remote/ssh#forward-ports).
|
||
- `hostRequirements` (`cpus`, `memory`, `storage`): checked against this machine and the Docker VM before building.
|
||
When they fall short, **Reopen in Container** (and MCP `devcontainer_up`) warns before running `devcontainer up`.
|
||
- Resource limits in `runArgs` (`--cpus`, `--memory` / `-m`, `--cpu-quota`) and Compose `deploy.resources.limits`:
|
||
read-only — OpenIDEA displays them alongside live usage without rewriting `devcontainer.json` or Compose files.
|
||
|
||
Language servers and debuggers that OpenIDEA installs go into the container, under the container user's
|
||
`~/.openidea/data`.
|
||
|
||
### Resource limits, usage and out-of-memory exits
|
||
|
||
- **While the container runs:** **Services › Docker › Dev Containers** and the remote window's status bar resources
|
||
widget show the container's CPU and memory limits next to current usage (`docker stats`), together with where the
|
||
limit is set (`devcontainer.json`, Docker Compose, or the Docker VM). The MCP `devcontainer_status` tool returns the
|
||
same limits, usage, `hostRequirements` check and OOM state.
|
||
- **When the container hits its memory limit:** If Docker reports `OOMKilled`, OpenIDEA explains
|
||
it in plain words (for example, _"The dev container ran out of its 4 GB memory limit."_) in the disconnect
|
||
notification and in **Services › Docker › Dev Containers**, with an action to open the `devcontainer.json` or Compose
|
||
file that sets the limit.
|
||
|
||
### Limits
|
||
|
||
- **File › Reopen in Container** uses `.devcontainer/devcontainer.json`, then `.devcontainer.json`. To select a
|
||
configuration in a subfolder of `.devcontainer/`, use the Welcome screen or the editor banner.
|
||
- **Reopen in Container** is available for local projects only, not from an SSH or WSL window.
|
||
- There is no command to attach to an arbitrary running container; the container always comes from the project's
|
||
`devcontainer.json`.
|
||
|
||
## Docker and Docker Compose run targets
|
||
|
||
A run target runs a run configuration somewhere other than your machine. Container targets rewrite the configuration
|
||
into a local `docker run --rm` (or `docker compose run --rm`) with the project bind-mounted, so the console, input,
|
||
**Stop** and test results work as for a local run.
|
||
|
||
<Steps>
|
||
<Step title="Add a target">
|
||
Open **Settings › Build, Execution, Deployment › Run Targets**, click **+**, and set **Type** to **Docker** or
|
||
**Docker Compose**.
|
||
</Step>
|
||
<Step title="Describe the container">
|
||
For **Docker**, enter the **Image** (for example `python:3.12`). For **Docker Compose**, list the **Compose files**
|
||
(empty uses the project's default file) and the **Service**.
|
||
</Step>
|
||
<Step title="Use it">
|
||
Pick the target under **Run on** in a run configuration, or make it the **Default run target**.
|
||
</Step>
|
||
</Steps>
|
||
|
||
Container target options:
|
||
|
||
| Option | Meaning |
|
||
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||
| **Docker connection** | Which Docker daemon to use; **Docker CLI default** uses the Docker CLI's own default. Only daemons on this machine can mount the project. |
|
||
| **Container folder** | Where the project is mounted. Paths and the working directory are mapped into it. For Compose, empty means where the service mounts the project. |
|
||
| **Published ports** | Ports to publish, for example `8000:8000`. |
|
||
| **Run options** | Extra `docker run` options, for example `--network host`. |
|
||
| **Run as the image's user, not the project folder's owner (Linux)** | On Linux the container runs as the owner of the project folder by default, so the files it writes stay yours. Tick this to keep the image's user. |
|
||
|
||
A container target can also be the project's Python interpreter, so the editor resolves the packages installed in the
|
||
image; see [Python](/en/languages/python#a-docker-or-compose-run-target-as-the-interpreter).
|
||
|
||
See [Run configurations](/en/guide/run) for run targets in general, including SSH targets.
|