这有效:
# echo 1 and exit:
$ docker run -i -t image /bin/bash -c "echo 1"
1
# exit
# echo 1 and return shell in docker container:
$ docker run -i -t image /bin/bash -c "echo 1; /bin/bash"
1
root@4c064f2554de:/#
Run Code Online (Sandbox Code Playgroud)
问题:我如何将source文件放入shell?(这不起作用)
$ docker run -i -t image /bin/bash -c "source <(curl -Ls git.io/apeepg) && /bin/bash"
# content from http://git.io/apeepg is sourced and shell is returned
root@4c064f2554de:/#
Run Code Online (Sandbox Code Playgroud)
Mic*_*ter -2
我认为你不能这样做,至少现在不能。您可以做的是修改您的图像,并添加您想要获取的文件,如下所示:
FROM image
ADD my-file /my-file
RUN ["source", "/my-file", "&&", "/bin/bash"]
Run Code Online (Sandbox Code Playgroud)