Replies: 2 comments 1 reply
-
@lonix1 what you can do today is use {
"key": "alt+t",
"command": "workbench.action.tasks.runTask"
} The automatically-run task can be anything, but in your scenario it makes sense to use a Docker Compose task provided by the extension: https://code.visualstudio.com/docs/containers/reference#_docker-compose-task Let us know if that helps! |
Beta Was this translation helpful? Give feedback.
-
@karolz-ms I found another way which doesn't even need the extension: The keybinding: {
"key": "ctrl+t",
"command": "workbench.action.tasks.runTask",
"args": "toggle database",
}, The task: {
"label": "toggle database",
"type": "shell",
"command": "CONTAINER=container_name; FILE=${workspaceFolder}/foo/docker-compose.yml; [ $(docker ps --format='{{.Names}}' | grep $CONTAINER | wc -l) -eq 0 ] && docker-compose --file $FILE up --detach || docker-compose --file $FILE down",
}, I couldn't find a way to break the command into separate lines, but it works. This toggles the container up/down each time one presses the shortcut. It doesn't do auto start/stop with vscode open/close, but it's still useful. Thanks for pointing me in the right direction! |
Beta Was this translation helpful? Give feedback.
-
My workspace defines various
docker-compose.yml
files - e.g. to start a database, or some other service which I need while coding. So when I open the workspace, I first have to start those containers.Please consider a feature which auto-starts specific containers when the workspace is opened, and auto-stops/removes them when the workspace is closed.
That would greatly simplify development.
The compose files could be specified in a
project/.vscode/.docker
config file, e.g.:(That would be better than specifying it in the
project/.vscode/settings.json
as that would be checked into source control, whereas theproject/.vscode/.docker
config file is a per-developer preference - e.g. some devs must start the database, whereas others may start redis or whatever.)Beta Was this translation helpful? Give feedback.
All reactions