小编cch*_*ney的帖子

Expand ARG value in CMD [Dockerfile]

I'm passing a build argument into: docker build --build-arg RUNTIME=test

In my Dockerfile I want to use the argument's value in the CMD:

CMD ["npm", "run", "start:${RUNTIME}"]

Doing so results in this error: npm ERR! missing script: start:${RUNTIME} - it's not expanding the variable

I read through this post: Use environment variables in CMD

So I tried doing: CMD ["sh", "-c", "npm run start:${RUNTIME}"] - I end up with this error: /bin/sh: [sh,: not found

Both errors occur when I …

docker dockerfile

3
推荐指数
1
解决办法
2516
查看次数

标签 统计

docker ×1

dockerfile ×1