I have some nice and clean solution using environment variables (bash syntax for default variable value, in my case it is latest
but you can use anything ), this is my compose:
version: '3'
services:
app:
build: .
image: myapp-name:${version:-latest}
build and push (if you need to push to the registry) with the default tag, change the version using environment variable and build and push again:
docker-compose build
docker-compose push
export version=0.0.1
docker-compose build
docker-compose push