troricleba
troricleba

Reputation: 151

Trying to connect"neither an image nor a build context specified."

Running docker-compose commands like build and up works.

However when I try to connect docker with VS Code I get this error:

The Compose file is invalid because:
Service your-service-name-here has neither an image nor a build context specified. At least one must be provided.

This is the compose file:

version: '3'
services:
  db:
    image: postgres
    ports:
      - "5432:5432"

  web:
    build: .
    command: bin/rails server --port 3000 --binding 0.0.0.0
    ports:
      - "3000:3000"
    links:
      - db
    volumes:
      - .:/myapp

Upvotes: 3

Views: 11307

Answers (2)

Diego Machaca
Diego Machaca

Reputation: 51

I very probably that your should be specific build context

build:
  context: . # if you stay on root project 

Upvotes: 3

Chiss
Chiss

Reputation: 21

Look at your devcontainer.json in the .devcontainer folder. Mine had an autogenerated docker-compose.yml from a previous experiment and it was a partially-filled template which could not work, hence the error message.

Found this by looking carefully at the command VSCode was trying to execute (the -f argument).

Cleaning up the .json config file solved the issue.

Upvotes: 2

Related Questions