0

I am trying to run the following command as part of a deployment in Gitlab.

TIMESTAMP=$(date +%s) docker stack deploy --with-registry-auth --compose-file $(`printf "docker-compose.%s.unimark.yaml" "$SRV_DEPLOY_ENV"`) unimark`

I am getting the following error. I am not sure what is going wrong here.

/bin/sh: eval: line 332: docker-compose.demo.unimark.yaml: not found
"docker stack deploy" requires exactly 1 argument.
See 'docker stack deploy --help'.
Usage:  docker stack deploy [OPTIONS] STACK
Deploy a new stack or update an existing stack

I also tried

DOCKER_COMPOSE_DEPLOY_FILE=`printf "docker-compose.%s.unimark.yaml" "$SRV_DEPLOY_ENV"`

TIMESTAMP=$(date +%s) docker stack deploy --with-registry-auth --compose-file $($DOCKER_COMPOSE_DEPLOY_FILE) unimark`

the same error saying docker-compose file cannot be found. I checked and the file is there in the same directory. Not sure if it has to do with some bash vs sh issue.

1

1 Answer 1

0

I think this is a problem with bash command substitution.

$(`printf "docker-compose.%s.unimark.yaml" "$SRV_DEPLOY_ENV"`)

or

DOCKER_COMPOSE_DEPLOY_FILE=`printf "docker-compose.%s.unimark.yaml" 
"$SRV_DEPLOY_ENV"`
$($DOCKER_COMPOSE_DEPLOY_FILE)

To bash is interpreted the same: please execute the command that is the result of this nested command.

Removing the backtick in the first instance or removing the parenthesis in the second one should do the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.