microsoft / vscode-dev-containers

NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
https://aka.ms/vscode-remote
MIT License
4.72k stars 1.41k forks source link

devcontainer fail to start when using docker-compose #1595

Closed loynoir closed 1 year ago

loynoir commented 2 years ago

Steps to Reproduce:

  1. vscode > devcontainer add config > show all > from compose
  2. Reopen in container
  3. Log
    Start: Run: docker inspect --type image reproduce_devcontainer_app
    Command failed: docker inspect --type image reproduce_devcontainer_app
  4. Debug
    $ docker image ls|grep reproduce
    reproduce_devcontainer-app                                              latest         xxx   About a minute ago   570MB

Expected

Start: Run: docker inspect --type image reproduce_devcontainer-app

Actual

Start: Run: docker inspect --type image reproduce_devcontainer_app
jkeech commented 2 years ago

Thanks for reporting! This looks like a duplicate of https://github.com/microsoft/vscode-dev-containers/issues/1567 / https://github.com/microsoft/vscode-remote-release/issues/7047

Which version of Remote - Containers are you using? It should be fixed in the latest versions: https://github.com/microsoft/vscode-remote-release/issues/7047#issuecomment-1212197426.

leorochael commented 1 year ago

Just as an additional point, since google searching led me here.

If you:

version: "3"
services:
  myservice:
    profiles:
      - development
    build:
      context: "."

Then when you call Dev Containers: Reopen in Container, you'll hit an error like:

[2022-12-09T13:04:06.542Z] Start: Run: docker inspect --type image my-project-myservice
[2022-12-09T13:04:06.561Z] Stop (19 ms): Run: docker inspect --type image myproject-myservice
[2022-12-09T13:04:07.487Z] Error fetching image details: No manifest found for docker.io/library/myproject-myservice.
[2022-12-09T13:04:07.487Z] Start: Run: docker pull myproject-myservice
[2022-12-09T13:04:07.615Z] Using default tag: latest
[2022-12-09T13:04:09.459Z] Error response from daemon: pull access denied for myproject-myservice, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
[2022-12-09T13:04:09.461Z] Stop (1974 ms): Run: docker pull myproject-myservice
[2022-12-09T13:04:09.461Z] []
[2022-12-09T13:04:09.461Z] Error: No such image: myproject-myservice

[2022-12-09T13:04:09.463Z] Error: Command failed: docker inspect --type image myproject-myservice

This is caused by the profiles clause in the yaml. VS.Code selected a service that docker-compose will not try to build unless --profile <profile name> is added as an option to docker-compose, like:

But dev-containters doesn't pass that option, despite allowing you to select a service that can only be built or brought up by specifying a profile.

There is an issue requesting profile support for docker-compose at microsoft/vscode-remote-release#5795