Docker container sample for Visual Studio Code Remote Development.
Official reference: https://code.visualstudio.com/docs/remote/containers
Copy Dockerfile to .devcontainer directory in workspace, and customize Dockerfile.
. (workspace)
├── .devcontainer
| ├──Dockerfile
| └── devcontainer.json (generated by Visual Studio Code)
|
other files
devcontainer.json sample:
{
"name": "Python 3.8",
"dockerFile": "Dockerfile",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"editor.formatOnSave": true,
"python.linting.lintOnSave": true
},
"extensions": [
"ms-python.python"
]
}
. (workspace)
├── .devcontainer
| ├── devcontainer.json (generated by Visual Studio Code)
| ├── docker-compose.yml (docker-compose settings)
| ├── devcontainer.extend.yml (for remove develop settings)
| ├── python-app
| | └── Dockerfile
| └── db
| └── Dockerfile
|
other files
devcontainer.json sample:
{
"name": "Python with database App",
// "dockerComposeFile" is used for -f option of docker-compose command.
"dockerComposeFile": [
"docker-compose.yml",
"devcontainer.extend.yml"
],
"service": "python-app",
"workspaceFolder": "/workspace",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"editor.formatOnSave": true,
"python.linting.lintOnSave": true
},
"extensions": [
"ms-python.python"
],
"shutdownAction": "stopCompose"
}
docker-compose.yml sample:
version: "3"
services:
python-app:
image: python-app
container_name: python-app
build:
context: ./python-app
dockerfile: Dockerfile
networks:
- python-app-network
db:
image: db
container_name: db
build:
context: ./db
dockerfile: Dockerfile
networks:
- python-app-network
networks:
python-app-network:
name: python-app-network
driver: bridge
devcontainer.extend.yml sample:
version: "3"
services:
python-app:
# tty is required if Visual Studio Code attaches to this container.
tty: true
# '/workspace' is value of 'workspaceFolder' in '.devcontainer/devcontainer.json'.
volumes:
- ./:/workspace:cached