How to pass the version to docker-compose?
Another way to execute the @golfNintyNine answer is putting inside docker-compose.yml the environment variable:

serviceName:
image: "imageName:${VERSION}"


And then executing simply:

$ VERSION=2 docker-compose up


Also you can put all together inside script file like this:

#!/bin/bash

function usage {
    cat &lt;&lt; EOF &gt;&amp;2
Version argument is required, please use -v or --version.
EOF
    exit 1
}


OPTS=`getopt -o v: -l version: -- "$@"`


if [ $? != 0 ] ; then usage ; fi

eval set -- "$OPTS"

while true; do
    case "$1" in
        -v | --version ) export VERSION="$2"; shift 2;;
        -- ) shift; break ;;
    esac
done

if [ -z $VERSION ]
then
    usage
fi

docker-compose up