Skip to content

Commit efcaa64

Browse files
committed
2 parents 8efcf1b + e6fab82 commit efcaa64

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

blogs/2019/05/02/remote-development.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Author: Chris Dias
1212

1313
May 2, 2019 by The VS Code Team, [@code](https://twitter.com/code)
1414

15-
## TL&DR;
15+
## TL;DR
1616

1717
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).
1818

@@ -152,4 +152,4 @@ Let us know what you think!
152152

153153
Happy Coding,
154154

155-
The [@code](https://twitter.com/code) team
155+
The [@code](https://twitter.com/code) team

docs/remote/containers.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Workspace files are mounted from the local file system or copied or cloned into
1515

1616
![Container Architecture](images/containers/architecture-containers.png)
1717

18-
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**.
1919

2020
## Getting started
2121

@@ -65,7 +65,6 @@ Let's start out by using a sample project to try things out.
6565
git clone https://github.com/Microsoft/vscode-remote-try-java
6666
git clone https://github.com/Microsoft/vscode-remote-try-dotnetcore
6767
git clone https://github.com/Microsoft/vscode-remote-try-php
68-
git clone https://github.com/Microsoft/vscode-remote-try-ruby
6968
git clone https://github.com/Microsoft/vscode-remote-try-rust
7069
git clone https://github.com/Microsoft/vscode-remote-try-cpp
7170
```
@@ -384,7 +383,7 @@ apt-get install <package>
384383
385384
Documentation for the 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 root in 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.
386385
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.
388387
389388
### Using a Dockerfile
390389
@@ -400,22 +399,23 @@ For example:
400399
401400
```json
402401
{
403-
"name": "My Container App",
402+
"name": "My Node.js App",
404403
"dockerFile": "Dockerfile",
405404
"appPort": 3000,
406405
"extensions": [
407406
"dbaeumer.vscode-eslint"
408-
]
407+
],
408+
"postCreateCommand": "npm install"
409409
}
410410
```
411411
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`.
413413
414414
The example below uses `runArgs` to change the security policy to enable the ptrace system call for Go development container:
415415
416416
```json
417417
{
418-
"name": "My Container App",
418+
"name": "My Go App",
419419
"dockerFile": "Dockerfile",
420420
"extensions": [
421421
"ms-vscode.go"
@@ -436,8 +436,9 @@ In some cases, a single container environment isn't sufficient. Fortunately, VS
436436
You can either:
437437
438438
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).
441442
442443
> **Note:** Alpine Linux and Windows based containers are not currently supported.
443444
@@ -459,7 +460,15 @@ For example:
459460
460461
See the [devcontainer.json reference](#devcontainerjson-reference) for information other available properties such as the `workspaceFolder` and `shutdownAction`.
461462
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`:
464+
465+
```json
466+
"dockerComposeFile": "docker-compose.devcontainer.yml",
467+
```
468+
469+
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.
463472
464473
```yaml
465474
volumes:
@@ -481,7 +490,7 @@ For example:
481490
482491
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.
483492
484-
For example, consider this additional `.devcontainer/docker-compose.yml` file:
493+
For example, consider this additional `.devcontainer/docker-compose.extend.yml` file:
485494
486495
```yaml
487496
version: '3'
@@ -501,14 +510,14 @@ version: '3'
501510
command: sleep infinity
502511
```
503512
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:
505514
506515
```json
507516
{
508517
"name": "[Optional] Your project name here",
509518
"dockerComposeFile": [
510519
"../docker-compose.yml",
511-
"docker-compose.yml"
520+
"docker-compose.extend.yml"
512521
],
513522
"service": "your-service-name-here",
514523
"workspaceFolder": "/workspace",
@@ -519,7 +528,7 @@ This same file can provide additional settings, such as port mappings, as needed
519528
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:
520529
521530
```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
523532
```
524533
525534
### Using an updated Dockerfile to automatically install more tools
@@ -551,11 +560,11 @@ The following are dev container definitions that use Docker Compose:
551560
552561
* [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.
553562
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.
555564
556565
* [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.
557566
558-
## Using Docker or Kubernetes from a container
567+
### Using Docker or Kubernetes from a container
559568
560569
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.
561570
@@ -577,7 +586,7 @@ See the following examples dev containers for additional information:
577586
| `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. |
578587
| `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). |
579588
| `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 `[]`. |
581590
| `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 `[]`. |
582591
| `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`. |
583592
| `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
607616
608617
### Docker limitations
609618
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.
611620
* 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.
612621
* 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.
613622
* 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

Comments
 (0)