How to tag docker image with docker-compose
I'd like to add that you can also manage your tag versions through environment variables or an .env file.
https://docs.docker.com/compose/environment-variables/#the-env-file
export TAG=1.11
Example:
version: '3.3'
services:
baggins.api.rest:
image: my.image.name:${TAG}
build:
context: ../..
dockerfile: app/Docker/Dockerfile.release
ports:
...
docker-compose config
to validate
In my ci pipeline my first build is tagged with a throwaway value used for running tests. Then I change the tag to latest and rebuild again (nearly instant since it's all cached) before pushing to the registry.
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
Original answer Nov 20 '15:
No option for a specific tag as of Today. Docker compose just does its magic and assigns a tag like you are seeing. You can always have some script call docker tag <image> <tag>
after you call docker-compose.
Now there's an option as described above or here
build: ./dir
image: webapp:tag