gpt4 book ai didi

bash - docker run -i -t image/bin/bash - 首先是源文件

转载 作者:IT老高 更新时间:2023-10-28 12:46:43 24 4
gpt4 key购买 nike

这行得通:

# 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:/#

问题:我如何将文件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:/#

最佳答案

就我而言,我在 Dockerfile 中使用 RUN source 命令(将使用/bin/bash 运行)来为 node.js 安装 nvm

这是一个例子。

FROM ubuntu:14.04

RUN rm /bin/sh && ln -s /bin/bash /bin/sh
...
...
RUN source ~/.nvm/nvm.sh && nvm install 0.11.14

关于bash - docker run -i -t image/bin/bash - 首先是源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23031753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com