hlv_trinh
hlv_trinh

Reputation: 132

How to pass nested command to Docker run?

In my CI build, I'd like to print a formatted string which is built from some nested commands by Docker like:

docker run -t --rm -v /mysrc:/src -w /src node:lts echo "My project uses `npm list aLibrary`"

On bash, the command echo "My project uses `npm list aLibrary`" just runs perfectly, but when passing to Docker, neither backtick`nor $() can be interpolated.

Anyone could help?

I've thought about making a .sh file to mount into the docker container, but a file would need a place to be stored, I think this simple CI script shouldn't be in a file.

Upvotes: 1

Views: 1447

Answers (2)

LinPy
LinPy

Reputation: 18578

this will work :

echo "My project uses `/usr/local/bin/npm list aLibrary`"

you need to supply the full path

Upvotes: 2

Sreejith
Sreejith

Reputation: 464

Try:

bash -c 'echo "My project uses `npm list aLibrary`"'

Upvotes: 3

Related Questions