1

I recently installed docker and was playing around docker compose.

$ docker-compose --version

docker-compose version 1.23.2, build 1110ad01

$ docker --version

Docker version 18.09.1, build 4c52b90

docker-compose.yaml contents:

  services:
  code:
    image: code
    build:
      context: ../../../
      labels:
        build-date: "Wed Jan 16 21:36:30 UTC 2019"
        git-commit: "abcd036f79e169c9df6b60d11ef5a105e020918d"
        git-branch: "master"
        git-repository: "shaml"
        ecr-repository: "code"
        build-tag: "latest"
      dockerfile: ./deploy/Dockerfile

When I am labeling my docker image via docker-compose it's throwing me an error. I followed the syntax from https://docs.docker.com/compose/compose-file/#labels.

I am getting the following error when I am trying to run

docker-compose build

ERROR: The Compose file './docker-compose.yaml' is invalid because:
code-build contains unsupported option: 'labels'

I tried upgrading the docker and docker-compose version but seems like I do have the updated version.

Please help

1 Answer 1

0

If you do not specify a version number, compose will default to a deprecated version 1 format. You also need to fix the indentation on the services section (it should not be at the same level as the services it contains, and it cannot be empty).

version: '3'
services:
  code:
    image: code
    build:
      context: ../../../
      labels:
        build-date: "Wed Jan 16 21:36:30 UTC 2019"
        git-commit: "abcd036f79e169c9df6b60d11ef5a105e020918d"
        git-branch: "master"
        git-repository: "shaml"
        ecr-repository: "code"
        build-tag: "latest"
      dockerfile: ./deploy/Dockerfile
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .