Search code examples
dockerdocker-composedocker-stack

Invalid reference format error while executing docker stack deploy command


We are getting invalid reference format error while executing the below command:

$VAR=VALUE sudo docker stack deploy --compose-file docker-compose.yml service-name

However, the following command works without resulting in error:

sudo docker stack deploy --compose-file docker-compose.yml service-name

VAR is a variable in docker-compose.yml file

Can anyone guide me to solve this issue?


Solution

  • sudo VAR=VALUE docker stack deploy -c docker-compose.yml service-name
    

    The '$' sign expands the value so you don't want it on the left side of an '=' sign