Skip to content

Commit

Permalink
Update port info, Pylance
Browse files Browse the repository at this point in the history
  • Loading branch information
bamurtaugh committed Apr 16, 2021
1 parent c115d22 commit a8a25f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
Expand All @@ -33,23 +34,30 @@

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python"
"ms-python.python",
"ms-python.vscode-pylance"
],

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

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install -r requirements.txt",

// Use 'portsAttributes' to set default properties for specific forwarded ports.
// You can use a port number (i.e. 3000), range of numbers, or a regex to match the running process.
"portsAttributes": {
"9000": {
"label": "Hello Remote World",
"onAutoForward": "notify"
}
},

// 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": "pip3 install -r requirements.txt",

// Comment out to connect as root instead.
"remoteUser": "vscode"
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ 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.

**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.
- Uncomment the `forwardedPorts` attribute and adjust the port number as needed.
- Modify the `"onAutoForward"` attribute in your `portsAttributes` to `"openBrowser"`.
- Press <kbd>F1</kbd> and select the **Remote-Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up.

### More samples
Expand Down

0 comments on commit a8a25f8

Please sign in to comment.