Skip to content

Commit 89fdeff

Browse files
authored
Merge pull request #20 from microsoft/ports
Update ports and use Pylance
2 parents c115d22 + 7ed7ba7 commit 89fdeff

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.devcontainer/devcontainer.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"settings": {
1919
"terminal.integrated.shell.linux": "/bin/bash",
2020
"python.pythonPath": "/usr/local/bin/python",
21+
"python.languageServer": "Pylance",
2122
"python.linting.enabled": true,
2223
"python.linting.pylintEnabled": true,
2324
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
@@ -33,23 +34,29 @@
3334

3435
// Add the IDs of extensions you want installed when the container is created.
3536
"extensions": [
36-
"ms-python.python"
37+
"ms-python.python",
38+
"ms-python.vscode-pylance"
3739
],
3840

3941
// Use 'forwardPorts' to make a list of ports inside the container available locally.
4042
// "forwardPorts": [9000],
4143

42-
// Use 'postCreateCommand' to run commands after the container is created.
43-
"postCreateCommand": "pip3 install -r requirements.txt",
44-
45-
// Use 'portsAttributes' to set default properties for specific forwarded ports.
44+
// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
4645
"portsAttributes": {
4746
"9000": {
4847
"label": "Hello Remote World",
4948
"onAutoForward": "notify"
5049
}
5150
},
5251

53-
// Comment out to connect as root instead.
52+
// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
53+
// "otherPortsAttributes": {
54+
// "onAutoForward": "silent"
55+
// },
56+
57+
// Use 'postCreateCommand' to run commands after the container is created.
58+
"postCreateCommand": "pip3 install -r requirements.txt",
59+
60+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
5461
"remoteUser": "vscode"
5562
}

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ Some things to try:
6868

6969
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.
7070

71-
**Forward a port statically:** As an example change, let's forward a port statically in the `.devcontainer/devcontainer.json` file.
72-
73-
> **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.
71+
**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.
7472

7573
- Open the `.devcontainer/devcontainer.json` file.
76-
- Uncomment the `forwardedPorts` attribute and adjust the port number as needed.
74+
- Modify the `"onAutoForward"` attribute in your `portsAttributes` from `"notify"` to `"openBrowser"`.
7775
- Press <kbd>F1</kbd> and select the **Remote-Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up.
7876

7977
### More samples

0 commit comments

Comments
 (0)