question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variable interpolation in CMD

See original GitHub issue

Describe the bug Running a CMD with a command that uses an environment variable does not interpolate it. In package.json:

"scripts": {
  "storybook": "start-storybook -p ${STORYBOOK_PORT:-9001}",
}

In Dockerfile:

ENV STORYBOOK_PORT=300

CMD [ "/bin/sh", "-c", "npm run storybook" ]

OR

ENV STORYBOOK_PORT=3000

CMD [ "/bin/sh", "-c", "npm", "run", "storybook" ]

Results in $STORYBOOK_PORT always be an empty string.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Schnitzelcommented, Mar 28, 2019

@alexdesignworks You can just change the CMD:

CMD [ "/bin/bash", "-c", "npm run storybook" ]

and then it’s running is bash

0reactions
Schnitzelcommented, Mar 28, 2019

plus the reason to now use bash by default is that bash is not by default in the alpine upstream images and we want to keep the images as small and as upstreamy as possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Batch Script - String Interpolation - Tutorialspoint
String interpolation is a way to construct a new String value from a mix of constants, variables, literals, and expressions by including their...
Read more >
Windows Batch Files - Interpolate environment variables into ...
In Batch SET command the variable name is the complete string before the equal sign (including spaces) and the variable value is the ......
Read more >
Batch Script - String Interpolation - GeeksforGeeks
String interpolation is a technical way of saying parsing a value that might be a variable into a string. It is an important...
Read more >
Shell Command Substitution – interpolate stdout into a ...
You can use command substitution to interpolate text anywhere that you might use a shell variable. Command substitution is especially useful in shell...
Read more >
Environment variables in Compose | Docker Documentation
How to set, use and manage environment variables in Compose. ... a path to your environment variables file using the --env-file command line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found