You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This lets VS Code provide a **local-quality development experience** — including full IntelliSense (completions), code navigation, and debugging — **regardless of where your code is hosted**.
18
+
This lets VS Code provide a **local-quality development experience** — including full IntelliSense (completions), code navigation, and debugging — **regardless of where your tools (or code) is located**.
19
19
20
20
## Getting started
21
21
@@ -384,7 +384,7 @@ apt-get install <package>
384
384
385
385
Documentation forthe software you want to install will usually provide specific instructions, but note that you typically do **not need to prefix commands with `sudo`** given you are likely running as rootin the container. If you are not already root, read the directions for the image you've selected to learn how to install additional software. If you would **prefer not to run as root**, see the [tips and tricks](/docs/remote/troubleshooting.md#adding-a-nonroot-user-to-your-dev-container) article for how to set up a separate user.
386
386
387
-
You can also use a `Dockerfile` to create a custom image with additional software pre-installed. We'll cover this scenario next.
387
+
However, note that if you **rebuild** the container, you will have to **re-install** anything you've installed manually. To avoid this problem, you can use a `Dockerfile` to create a custom image with additional software pre-installed. We'll cover this scenario next.
388
388
389
389
### Using a Dockerfile
390
390
@@ -400,22 +400,23 @@ For example:
400
400
401
401
```json
402
402
{
403
-
"name": "My Container App",
403
+
"name": "My Node.js Container App",
404
404
"dockerFile": "Dockerfile",
405
405
"appPort": 3000,
406
406
"extensions": [
407
407
"dbaeumer.vscode-eslint"
408
-
]
408
+
],
409
+
"postCreateCommand": "npm install"
409
410
}
410
411
```
411
412
412
-
See the [devcontainer.json reference](#devcontainerjson-reference) for information on other available properties such as the `appPort` and `extensions` list.
413
+
See the [devcontainer.json reference](#devcontainerjson-reference) for information on other available properties such as `appPort`, the `extensions` list, and `postCreateCommand`.
413
414
414
415
The example below uses `runArgs` to change the security policy to enable the ptrace system call for Go development container:
415
416
416
417
```json
417
418
{
418
-
"name": "My Container App",
419
+
"name": "My Go Container App",
419
420
"dockerFile": "Dockerfile",
420
421
"extensions": [
421
422
"ms-vscode.go"
@@ -436,8 +437,9 @@ In some cases, a single container environment isn't sufficient. Fortunately, VS
436
437
You can either:
437
438
438
439
1. Reuse an existing `docker-compose.yml` unmodified.
439
-
2. [Extend your existing Docker Compose configuration](#extending-your-docker-compose-file-for-development) for development.
440
-
3. Use the command line (for example `docker-compose up`) and [attach to an already running container](#attaching-to-running-containers).
440
+
2. Make a copy of your exiting `docker-compose.yml` that you use for development.
441
+
3. [Extend your existing Docker Compose configuration](#extending-your-docker-compose-file-for-development) for development.
442
+
4. Use the command line (for example `docker-compose up`) and [attach to an already running container](#attaching-to-running-containers).
441
443
442
444
> **Note:** Alpine Linux and Windows based containers are not currently supported.
443
445
@@ -459,12 +461,20 @@ For example:
459
461
460
462
See the [devcontainer.json reference](#devcontainerjson-reference) for information other available properties such as the `workspaceFolder` and `shutdownAction`.
461
463
464
+
You could also refer to a development copy of your Docker Compose file. For example, if you had `.devcontainer/docker-compose.devcontainer.yml`, just change the following line:
You can also avoid making a copy of your Docker Compose file by extending your Docker Compose file. We'll cover that [next](#extending-your-docker-compose-file-for-development).
471
+
462
472
Note that you may want to alter your existing Docker Compose file to mount your local`.gitconfig` folder so you don't have to set up Git inside of the container if you install it. (See [below](#extending-your-docker-compose-file-for-development) if you'd prefer not to alter your existing files.)
463
473
464
474
```yaml
465
475
volumes:
466
476
# This lets you avoid setting up Git again in the container
467
-
- ~/.gitconfig:/root/.gitconfig
477
+
- ~/.gitconfig:~/.gitconfig
468
478
```
469
479
470
480
After making edits, you can test by running the **Remote-Containers: Reopen Folder in Container** or **Remote-Containers: Rebuild Container** commands. Once the container is been created, the local filesystem is automatically mapped into the container and you can start working with it from VS Code.
@@ -481,7 +491,7 @@ For example:
481
491
482
492
You can solve these and other issues like them by extending your entire Docker Compose configuration with [multiple `docker-compose.yml` files](https://docs.docker.com/compose/extends/#multiple-compose-files) that override or supplement your primary one.
483
493
484
-
For example, consider this additional `.devcontainer/docker-compose.yml` file:
494
+
For example, consider this additional `.devcontainer/docker-compose.extend.yml` file:
485
495
486
496
```yaml
487
497
version: '3'
@@ -495,20 +505,20 @@ version: '3'
495
505
- ..:/workspace
496
506
497
507
# This lets you avoid setting up Git again in the container
498
-
- ~/.gitconfig:/root/.gitconfig
508
+
- ~/.gitconfig:~/.gitconfig
499
509
500
510
# Overrides default command so things don't shut down after the process ends.
501
511
command: sleep infinity
502
512
```
503
513
504
-
This same file can provide additional settings, such as port mappings, as needed. To use it, reference your original `docker-compose.yml` file in addition to this one in`.devcontainer/devcontainer.json` as follows:
514
+
This same file can provide additional settings, such as port mappings, as needed. To use it, reference your original `docker-compose.yml` file in addition to this one in`.devcontainer/devcontainer.extend.json` as follows:
505
515
506
516
```json
507
517
{
508
518
"name": "[Optional] Your project name here",
509
519
"dockerComposeFile": [
510
520
"../docker-compose.yml",
511
-
"docker-compose.yml"
521
+
"docker-compose.extend.yml"
512
522
],
513
523
"service": "your-service-name-here",
514
524
"workspaceFolder": "/workspace",
@@ -551,7 +561,7 @@ The following are dev container definitions that use Docker Compose:
551
561
552
562
* [Node.js & MongoDB](https://aka.ms/vscode-remote/samples/node-mongo) - A Node.js container that connects to a Mongo DB in a different container.
553
563
554
-
* [Python & PostGreSQL](https://aka.ms/vscode-remote/samples/python-postgresl) - A Python container that connects to PostGreSQL in a different container.
564
+
* [Python & PostgreSQL](https://aka.ms/vscode-remote/samples/python-postgresl) - A Python container that connects to PostGreSQL in a different container.
555
565
556
566
* [Docker-in-Docker Compose](https://aka.ms/vscode-remote/samples/docker-in-docker-compose) - Includes the Docker CLI and illustrates how you can use it to access your local Docker install from inside a dev container by volume mounting the Docker Unix socket.
557
567
@@ -577,7 +587,7 @@ See the following examples dev containers for additional information:
577
587
|`image`| string |**Required** when [using an image](#using-an-existing-container-image). The name of an image in a container registry ([DockerHub](https://hub.docker.com), [Azure Container Registry](https://azure.microsoft.com/services/container-registry/)) that VS Code should use to create the dev container. |
578
588
|`dockerFile`| string |**Required** when [using a Dockerfile](#using-a-dockerfile). The location of a [Dockerfile](https://docs.docker.com/engine/reference/builder/) that defines the contents of the container. The path is relative to the `devcontainer.json` file. You can find a number of sample Dockerfiles for different runtimes [in this repository](https://github.com/Microsoft/vscode-dev-containers/tree/master/dev-containers). |
579
589
|`context`| string | Path that the Docker build should be run from relative to `devcontainer.json`. For example, a value of `".."` would allow you to reference content in sibling directories. Defaults to `"."`. |
580
-
|`appPort`| integer, string, or array | A port or array of ports that should be made available locally when the container is running (beyond those already exposed by the container image). Defaults to `[]`. |
590
+
|`appPort`| integer, string, or array | A port or array of ports that should be made available locally when the container is running. Defaults to `[]`. |
581
591
|`runArgs`| array | An array of [Docker CLI arguments](https://docs.docker.com/engine/reference/commandline/run/) that should be used when running the container. Defaults to `[]`. |
582
592
|`overrideCommand`| boolean | Tells VS Code whether it should run `sleep infinity` when starting the container instead of the default command to prevent the container from immediately shutting down if the default command fails. Defaults to `true`. |
583
593
|`shutdownAction`| enum: `none`, `stopContainer`| Indicates whether VS Code should stop the container when the VS Code window is closed / shut down. Defaults to `stopContainer`. |
@@ -607,7 +617,7 @@ See [here for a list of active issues](https://aka.ms/vscode-remote/containers/i
607
617
608
618
### Docker limitations
609
619
610
-
* First time installs of Docker Desktop for Windows will require an additional "sharing" step to give your container access to local source code. However, step may not work with certain AAD (email based) identities. See [Docker Desktop for Windows tips](/docs/remote/troubleshooting.md#docker-desktop-for-windows-tips) and [Enabling file sharing in Docker Desktop](/docs/remote/troubleshooting.md#enabling-file-sharing-in-docker-desktop) for details and workarounds.
620
+
* First time installs of Docker Desktop for Windows will require an additional "sharing" step to give your container access to local source code. However, this step may not work with certain AAD (email based) identities. See [Docker Desktop for Windows tips](/docs/remote/troubleshooting.md#docker-desktop-for-windows-tips) and [Enabling file sharing in Docker Desktop](/docs/remote/troubleshooting.md#enabling-file-sharing-in-docker-desktop) for details and workarounds.
611
621
* You may see errors if you sign into Docker with your email address instead of your Docker ID. This is a known issue and can be resolved by signing in with your Docker ID instead. See Docker issue [#935](https://github.com/docker/hub-feedback/issues/935#issuecomment-300361781) for details.
612
622
* If you see high CPU spikes for `com.docker.hyperkit` on macOS, this may be due to a [known issue with Docker for Mac](https://github.com/docker/for-mac/issues/1759). See the Docker issue for details.
613
623
* If you see either of these messages building a Dockerfile, you may be hitting a known Docker issue with Debian 8 (Jessie):
0 commit comments