version: 3

services:
  foo-service:
    # ...
  bar-service:
    # ...

Context and Dockerfile

For more info, see Build definition in the docs.

services:
  my-service:
    build:
      context: .
services:
  my-service:
    image: user/foo
    build:
      context: ../my-dir
      dockerfile: foo.Dockerfile

Warning as per the docs - never use / as context as it will copy everything on your hard drive to the image.