microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.18k stars 508 forks source link

No services were found in the compose document(s). Did you mean to use profiles instead? #4264

Closed arisliang closed 2 months ago

arisliang commented 3 months ago

image

When right click on the docker-compose.yml file, and select 'Compose up - selected services', no service is found, even though there are services in the file, and 'Compose Up' is able to run all of them.

vscode: v1.87.2 docker extension: v1.29.0 Docker version 24.0.5, build ced0996

bwateratmsft commented 3 months ago

Can you share your compose document?

arisliang commented 3 months ago

don't think it's related to particular compose file. Same compose file works on another machine. And it seems any compose file would be the same on this machine. I created a minimal compose, it gives this error.

version: '3'
services:
  hello1:
    image: hello-world

  hello2:
    image: hello-world

More vscode info:

Version: 1.87.2 Commit: 863d2581ecda6849923a2118d93a088b0745d9d6 Date: 2024-03-08T15:14:59.643Z Electron: 27.3.2 ElectronBuildId: 26836302 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0 OS: Linux x64 6.5.0-26-generic snap

it's newly installed ubuntu 22.04. Never happend like this previously.

bwateratmsft commented 3 months ago

Do you have a non-default value for the setting docker.commands.composeUp or docker.commands.composeUpSubset? We use a docker-compose config --services to find the list of services, it's this config command that appears to be failing to find any services.

arisliang commented 3 months ago

I didn't change the default setting. I check in defaultSettings.json, for the 2 setting, it's:

    // Command templates for `docker-compose up` commands.
    "docker.commands.composeUp": [
        {
            "label": "Compose Up",
            "template": "${composeCommand} ${configurationFile} up ${detached} ${build}"
        }
    ],

    // Command templates for `docker-compose up <subset>` commands.
    "docker.commands.composeUpSubset": [
        {
            "label": "Compose Up",
            "template": "${composeCommand} ${profileList} ${configurationFile} up ${detached} ${build} ${serviceList}"
        }
    ],

docker.commands.composeUpSubset seems to expect profile list, what's that?

Removed the ${profileList} bit and add it to user setting, still the same error

bwateratmsft commented 3 months ago

The profile list is for when you're using compose profiles instead of service subsets. When they aren't in use, we substitute in an empty string, and vice versa with ${serviceList} when they are in use.

Can you run docker compose config --services and see what the output is?

arisliang commented 3 months ago

looks like the output is fine.

$ docker compose -f docker-compose-hello.yml config --services
hello1
hello2
bwateratmsft commented 3 months ago

This could be a Snap issue. Can you try the workaround in https://github.com/microsoft/vscode-docker/issues/3843#issue-1597589970 and see if that fixes it?

arisliang commented 2 months ago

set Docker Path, it doesn't seem to help. Restarting code doesn't help either.

Screenshot from 2024-04-05 11-24-15

bwateratmsft commented 2 months ago

This is a tough one. The call to docker compose config --services is succeeding, else a different error would be raised. However it is returning zero services when run. The only thing I can think to try is to run docker-compose -f docker-compose-hello.yml config --services--note the dash inbetween docker-compose, this is the old compose command. The system is supposed to autodetect that docker compose is available and use it, but there could be a bug in that logic.

AzCode-Bot commented 2 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

arisliang commented 2 months ago

FYI, after switch to deb installation, the issue is gone.