shell - docker run sh -c " "读取不到全局变量。
为情所困
为情所困 2017-04-26 09:02:23
0
1
633

在shell脚本中启动docker容器,脚本如下:

#!/bin/bash
export EXE_FILE="rdbs_cbb_test aom_cell_test" ;

docker login -u admin -p admin123 registry:5000;

docker run --rm \
registry:5000/compiler/cmake-unit-test:v1.0 bash -c ' \
#    EXE_FILE="rdbs_cbb_test aom_cell_test";\

    IFS=" " read -r -a arr <<< "$EXE_FILE";\
    for s in ${arr[@]}; \
    do \
        echo $s; \
    done \
  '

docker run 时执行的脚本读取$EXE_FILE变量的值为空,也测试了不使用export导出变量的方式,但是$EXE_FILE始终为空。

请问该如何向在docker run sh -c " "脚本中该如何读取到全局变量?

非常感谢。

为情所困
为情所困

reply all(1)
巴扎黑

docker run ... bash -c ...Use double quotes for the following commands, and change the content part to single quotes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!