Search code examples
dockerdocker-compose

How to tag docker image with docker-compose


I want to build image via docker-compose and set specific tag to it. Documentation says:

Compose will build and tag it with a generated name, and use that image thereafter.

But I can't find a way to specify tag and for built images I always see 'latest' tag.


Solution

  • It seems the docs/tool have been updated and you can now add the image tag to your script. This was successful for me.

    Example:

    version: '2'
    services:
    
      baggins.api.rest:
        image: my.image.name:rc2
        build:
          context: ../..
          dockerfile: app/Docker/Dockerfile.release
        ports:
          ...
    

    https://docs.docker.com/compose/compose-file/build

    There is also a separate key for Tags.