Docker container is not persistent when launched with compose configuration #1760
Description
I have a CMake project which I need to debug and compile for various platforms. For this specific example I use a minimalistic EulerOS image (it's almost empty, with nearly zero applications installed out of the box). This image comes from my company in-house registry, so in order to use it I manually create the following .devcontainer/devcontainer.json
configuration which refers to my custom image:
{
"image": "my_euler_image",
"customizations": {
"vscode": {
"extensions": ["streetsidesoftware.code-spell-checker"]
}
},
}
Then, if I open the workspace from within WSL, and run Dev Containers: Reopen in Container
it works just fine, i.e. VSCode automagically creates the container out of the image, mounts the workspace and keeps it running for me. However for my case I also need Kafka infrastructure, so I made a docker-compose.yaml
configuration:
version: "3"
services:
zookeeper:
...
kafka:
...
euleros:
tty: true
build: "path/to/Dockerfile"
depends_on:
- kafka
network:
default:
name: my_network
And changed the devcontainer.json correspondingly:
{
"dockerComposeFile": "path/to/docker-compose.yml"
"service": "euleros"
"runServices": [ "euleros" ],
"mounts":[
{ "source": "../relative/path/to/workspace", "target": "/mnt/path/to/workspace", "type": "volume" }
],
"workspceFolder": "/mnt/path/to/workspace",
"customizations": {
"vscode": {
"extensions": ["streetsidesoftware.code-spell-checker"]
}
}
}
In this case, however, if I run Dev Containers: Reopen in Container
, for some reason I have to mount the target service directory manually (by providing this information in the devcontainer.json file above). More importantly - VSCode doesn't maintain the persistence of the target service anymore in this case and get disconnected by timeout of tty mode.
Isn't VSCode supposed to keep it running and mount my workspace itself just like it does for single-image scenario? And if not, how do I handle it properly?