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
Copy file name to clipboardExpand all lines: blogs/2019/05/02/remote-development.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Author: Chris Dias
12
12
13
13
May 2, 2019 by The VS Code Team, [@code](https://twitter.com/code)
14
14
15
-
## TL&DR;
15
+
## TL;DR
16
16
17
17
Today we're excited to announce the preview of three new extensions for Visual Studio Code that enable seamless development in [Containers](https://www.docker.com/resources/what-container), remotely on physical or virtual machines, and with the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl). You can [get started](#get-started) right away by installing the [Remote Development Extension Pack](https://aka.ms/VSCodeRemoteExtensionPack).
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
@@ -65,7 +65,6 @@ Let's start out by using a sample project to try things out.
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
385
387
-
You can also use a `Dockerfile` to create a custom image with additional software pre-installed. We'll cover this scenario next.
386
+
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
387
389
388
### Using a Dockerfile
390
389
@@ -400,22 +399,23 @@ For example:
400
399
401
400
```json
402
401
{
403
-
"name": "My Container App",
402
+
"name": "My Node.js App",
404
403
"dockerFile": "Dockerfile",
405
404
"appPort": 3000,
406
405
"extensions": [
407
406
"dbaeumer.vscode-eslint"
408
-
]
407
+
],
408
+
"postCreateCommand": "npm install"
409
409
}
410
410
```
411
411
412
-
See the [devcontainer.json reference](#devcontainerjson-reference) for information on other available properties such as the `appPort` and `extensions` list.
412
+
See the [devcontainer.json reference](#devcontainerjson-reference) for information on other available properties such as `appPort`, the `extensions` list, and `postCreateCommand`.
413
413
414
414
The example below uses `runArgs` to change the security policy to enable the ptrace system call for Go development container:
415
415
416
416
```json
417
417
{
418
-
"name": "My Container App",
418
+
"name": "My Go App",
419
419
"dockerFile": "Dockerfile",
420
420
"extensions": [
421
421
"ms-vscode.go"
@@ -436,8 +436,9 @@ In some cases, a single container environment isn't sufficient. Fortunately, VS
436
436
You can either:
437
437
438
438
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).
439
+
2. Make a copy of your exiting `docker-compose.yml` that you use for development.
440
+
3. [Extend your existing Docker Compose configuration](#extending-your-docker-compose-file-for-development) for development.
441
+
4. Use the command line (for example `docker-compose up`) and [attach to an already running container](#attaching-to-running-containers).
441
442
442
443
> **Note:** Alpine Linux and Windows based containers are not currently supported.
443
444
@@ -459,7 +460,15 @@ For example:
459
460
460
461
See the [devcontainer.json reference](#devcontainerjson-reference) for information other available properties such as the `workspaceFolder` and `shutdownAction`.
461
462
462
-
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
+
You can also create a development copy of your Docker Compose file. For example, if you had `.devcontainer/docker-compose.devcontainer.yml`, you would just change the following line in `devcontainer.json`:
You can also avoid making a copy of your Docker Compose file by extending it with another one. We'll cover this topic in the [next section](#extending-your-docker-compose-file-for-development).
470
+
471
+
Note that you may want to include a volume mount to your local`.gitconfig` folder in your Docker Compose file so you don't have to set up Git inside of the container if you install it.
463
472
464
473
```yaml
465
474
volumes:
@@ -481,7 +490,7 @@ For example:
481
490
482
491
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
492
484
-
For example, consider this additional `.devcontainer/docker-compose.yml` file:
493
+
For example, consider this additional `.devcontainer/docker-compose.extend.yml` file:
485
494
486
495
```yaml
487
496
version: '3'
@@ -501,14 +510,14 @@ version: '3'
501
510
command: sleep infinity
502
511
```
503
512
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:
513
+
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
514
506
515
```json
507
516
{
508
517
"name": "[Optional] Your project name here",
509
518
"dockerComposeFile": [
510
519
"../docker-compose.yml",
511
-
"docker-compose.yml"
520
+
"docker-compose.extend.yml"
512
521
],
513
522
"service": "your-service-name-here",
514
523
"workspaceFolder": "/workspace",
@@ -519,7 +528,7 @@ This same file can provide additional settings, such as port mappings, as needed
519
528
VS Code will then**automatically use both files** when starting up any containers or you can start them yourself from the command line as follows:
520
529
521
530
```bash
522
-
docker-compose up -f docker-compose.yml -f .devcontainer/docker-compose.yml
531
+
docker-compose up -f docker-compose.yml -f .devcontainer/docker-compose.extend.yml
523
532
```
524
533
525
534
### Using an updated Dockerfile to automatically install more tools
@@ -551,11 +560,11 @@ The following are dev container definitions that use Docker Compose:
551
560
552
561
* [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
562
554
-
* [Python & PostGreSQL](https://aka.ms/vscode-remote/samples/python-postgresl) - A Python container that connects to PostGreSQL in a different container.
563
+
* [Python & PostgreSQL](https://aka.ms/vscode-remote/samples/python-postgresl) - A Python container that connects to PostGreSQL in a different container.
555
564
556
565
* [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
566
558
-
## Using Docker or Kubernetes from a container
567
+
### Using Docker or Kubernetes from a container
559
568
560
569
While you can build, deploy, and debug your application inside a dev container, you may also need to test it by running it inside a set of production-like containers. Fortunately, by installing the needed Docker or Kubernetes CLIs, you can build and deploy your app's container images from inside your dev container.
561
570
@@ -577,7 +586,7 @@ See the following examples dev containers for additional information:
577
586
|`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
587
|`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
588
|`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 `[]`. |
589
+
|`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
590
|`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
591
|`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
592
|`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 +616,7 @@ See [here for a list of active issues](https://aka.ms/vscode-remote/containers/i
607
616
608
617
### Docker limitations
609
618
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.
619
+
* 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
620
* 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
621
* 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
622
* 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