Merge pull request #32 from microsoft/ports

Update ports
This commit is contained in:
Brigit Murtaugh
2021-04-20 07:27:01 -07:00
committed by GitHub
2 changed files with 12 additions and 9 deletions

View File

@@ -30,10 +30,7 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [9000], // "forwardPorts": [9000],
// Use 'postCreateCommand' to run commands after the container is created. // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
// "postCreateCommand": "go version",
// Use 'portsAttributes' to set default properties for specific forwarded ports.
"portsAttributes": { "portsAttributes": {
"9000": { "9000": {
"label": "Hello Remote World", "label": "Hello Remote World",
@@ -41,6 +38,14 @@
} }
}, },
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. // Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
// "otherPortsAttributes": {
// "onAutoForward": "silent"
// },
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
// Uncomment to connect as a non-root user. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode" "remoteUser": "vscode"
} }

View File

@@ -61,12 +61,10 @@ Some things to try:
You may want to make changes to your container, such as installing a different version of a software or forwarding a new port. You'll rebuild your container for your changes to take effect. You may want to make changes to your container, such as installing a different version of a software or forwarding a new port. You'll rebuild your container for your changes to take effect.
**Forward a port statically:** As an example change, let's forward a port statically in the `.devcontainer/devcontainer.json` file. **Open browser automatically:** As an example change, let's update the `portsAttributes` in the `.devcontainer/devcontainer.json` file to open a browser when our port is automatically forwarded.
> **Note:** Remote-Containers and Codespaces also take care of dynamic port forwarding, but there may be instances in which we want to statically declare a forwarded port.
- Open the `.devcontainer/devcontainer.json` file. - Open the `.devcontainer/devcontainer.json` file.
- Uncomment the `forwardedPorts` attribute and adjust the port number as needed. - Modify the `"onAutoForward"` attribute in your `portsAttributes` from `"notify"` to `"openBrowser"`.
- Press <kbd>F1</kbd> and select the **Remote-Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up. - Press <kbd>F1</kbd> and select the **Remote-Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up.
5. **Refactoring - rename:** 5. **Refactoring - rename:**
- Open `hello.go`, select method name `Hello` press <kbd>F1</kbd> and run the **Rename Symbol** command. - Open `hello.go`, select method name `Hello` press <kbd>F1</kbd> and run the **Rename Symbol** command.