microsoft / microsoft/vscode-remote-release
Remote Containers performs 'docker-compose config' differently for different Compose versions
@chrmarti is already working on this.
Since Jul 6, 2022.
- Dominant language
- Dockerfile
- Stars
- 4.2k
- Forks
- 470
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
I have moved to Docker Compose V2 and now Remote Containers fail to start my services using docker-compose (see Logs). The issue looks similar to #5992, however turns out that the root cause is different. Before remote Containers starts services, it performs docker-compose config to check that compose files are valid. If we use example repo from "Steps to reproduce" section and run docker-compose config on it, the command will be executed successfully with both Compose V1 and Compose V2, but if we let Remote Containers do it, it will be successful with Compose V1 only. The reason for failure is here:
volumes:
- vscode-server:/home/posthelp/.vscode-server
- type: bind
# For Compose V1
source: $PWD
# For Compose V2
# source: ${PWD-/home}
target: /code
With Compose V2, Remote Containers docker-compose config fails because it fails to expand PWD environment variable. There is no such error when we perform the command manually, because, unlike Remote Containers which executes passed command directly without a shell, bash expands the variable and we get expected result. As a workaround we can use Compose default variable substitution as can be seen in commented line under #For Compose V2.
My guess is that Remote Containers executes commands for Compose V1 and V2 differently, which makes inconsistent results and problems like this that are difficult to debug.
- VSCode Version: 1.68.1
- Extension Version: 0.238.3
- OS version: Ubuntu 18.04
- Docker Compose Version: 2.6.0
- Remote Extension Type: Containers
- Logs:
[5231 ms] Start: Run: docker-compose -f /home/developer/vscode-compose-example/docker-compose.yml --profile * config
[5399 ms] Error: Command failed: docker-compose -f /home/developer/vscode-compose-example/docker-compose.yml --profile * config
[5399 ms] at Fa (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:230:813)
[5400 ms] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[5400 ms] at async RR (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:204:1340)
[5400 ms] at async PR (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:188:2240)
[5400 ms] at async zR (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:245:2177)
[5400 ms] at async nb (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:245:3110)
[5401 ms] at async JR (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:245:13046)
[5401 ms] at async KR (/home/developer/.vscode-remote-containers/dist/dev-containers-cli-0.238.3/dist/spec-node/devContainersSpecCLI.js:245:12802)
[5404 ms] Exit code 1
Steps to Reproduce:
- Clone example repo https://github.com/MartinsSmirnovs/vscode-compose-example
- Open with Visual Studio Code
- Ctrl+Shift+P
>Remote-Containers: Open Folder in Container- Select current directory when prompt opens
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.