<p>I think this is a problem with <a href="https://wiki.bash-hackers.org/syntax/expansion/cmdsubst" rel="nofollow noreferrer">bash command substitution</a>.</p>
<pre><code>$(`printf &quot;docker-compose.%s.unimark.yaml&quot; &quot;$SRV_DEPLOY_ENV&quot;`)
</code></pre>
<p>or</p>
<pre><code>DOCKER_COMPOSE_DEPLOY_FILE=`printf &quot;docker-compose.%s.unimark.yaml&quot; 
&quot;$SRV_DEPLOY_ENV&quot;`
$($DOCKER_COMPOSE_DEPLOY_FILE)
</code></pre>
<p>To bash is interpreted the same: please execute the command that is the result of this nested command.</p>
<p>Removing the backtick in the first instance or removing the parenthesis in the second one should do the trick.</p>

CC BY-SA 4.0
2022-04-13T13:54:40.030Z
2022-04-13T13:54:40.030Z
Alberto P.
<p>I am trying to run the following command as part of a deployment in Gitlab.</p>
<pre><code>TIMESTAMP=$(date +%s) docker stack deploy --with-registry-auth --compose-file $(`printf &quot;docker-compose.%s.unimark.yaml&quot; &quot;$SRV_DEPLOY_ENV&quot;`) unimark`
</code></pre>
<p>I am getting the following error. I am not sure what is going wrong here.</p>
<pre><code>/bin/sh: eval: line 332: docker-compose.demo.unimark.yaml: not found
&quot;docker stack deploy&quot; requires exactly 1 argument.
See 'docker stack deploy --help'.
Usage:  docker stack deploy [OPTIONS] STACK
Deploy a new stack or update an existing stack
</code></pre>
<p>I also tried</p>
<pre><code>DOCKER_COMPOSE_DEPLOY_FILE=`printf &quot;docker-compose.%s.unimark.yaml&quot; &quot;$SRV_DEPLOY_ENV&quot;`

TIMESTAMP=$(date +%s) docker stack deploy --with-registry-auth --compose-file $($DOCKER_COMPOSE_DEPLOY_FILE) unimark`
</code></pre>
<p>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 <code>bash</code> vs <code>sh</code> issue.</p>

CC BY-SA 4.0
2022-04-12T21:38:11.170Z
I'd cut on tracing to see what the resulting commands look like.  https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html
chicks
<gitlab><docker-swarm><bash>
docker command substitution fails on gitlab
CodeWeed
# docker command substitution fails on gitlab

(Asked by: username_0 on 2022-04-12)

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.

**Tags:** gitlab, docker-swarm, bash

> **Comments:**
> **username_1**: I'd cut on tracing to see what the resulting commands look like.  https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html  

---

## 1 answers

### Answer by username_2 on 2022-04-13. Score: 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.


---

