以下内容在$IPList | out-string
:
Dockerfile
我收到以下错误:
RUN if $SSH_PRIVATE_KEY -eq ""; then echo "SSH key is not set, aborting"; exit 1; else echo "SSH key is set"; fi
我想检查Step 4/15 : RUN if $SSH_PRIVATE_KEY -eq ""; then echo "SSH key is not set, aborting"; exit 1; else echo "SSH key is set"; fi
---> Running in 3bd29320f0e3
/bin/sh: -eq: command not found
变量是否包含任何内容。
答案 0 :(得分:2)
在变量周围添加引号(如果它可能包含空格),只需使用=
运算符进行字符串比较。
在Bourne shell中,它将是:
if [ "$SSH_PRIVATE_KEY" = "" ]; then echo "SSH key is not set, aborting"; exit 1; else echo "SSH key is set"; fi
答案 1 :(得分:0)
你必须在那里放方括号。否则测试一个空变量更好-z
切换。
RUN if [ -z "$SSH_PRIVATE_KEY" ]; then echo "SSH key is not set, aborting"; exit 1; else echo "SSH key is set"; fi