有些人赢了';不要在docker上工作,但在集装箱内工作

有些人赢了';不要在docker上工作,但在集装箱内工作,docker,dockerfile,luarocks,Docker,Dockerfile,Luarocks,我有一个Dockerfile用于一些lua和torch相关的任务,我正在尝试使用Luarock安装一些岩石 FROM ubuntu:14.04 RUN rm /bin/sh && ln -s /bin/bash /bin/sh RUN apt-get update -y RUN apt-get install -y curl git RUN curl -s https://raw.githubusercontent.com/torch/ezinstall/master/ins

我有一个Dockerfile用于一些lua和torch相关的任务,我正在尝试使用Luarock安装一些岩石

FROM ubuntu:14.04
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN apt-get update -y
RUN apt-get install -y curl git

RUN curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
RUN git clone https://github.com/torch/distro.git ~/torch --recursive
RUN cd ~/torch; ./install.sh

RUN source ~/.bashrc

RUN luarocks install nngraph
RUN luarocks install optim
RUN luarocks install nn

RUN luarocks install cltorch
RUN luarocks install clnn
docker build
在第一次Luarock调用之前运行良好:
RUN luarocks install nngraph
在该点停止并抛出错误:

/bin/sh: luarocks: command not found
如果我注释掉luarocks行,构建运行良好。使用该图像,我可以创建一个容器,并使用bash按预期运行luarock

当然,我并不特别希望每次启动容器时都要这样做,所以我想知道我是否可以做些什么来让它工作。我有一种感觉,这个问题与运行rm/bin/sh和&ln-s/bin/bash/bin/sh这一行有关,但我需要它才能运行这一行
运行source~/.bashrc


谢谢。

每个RUN命令都在自己的shell上运行,并提交一个新层

从Docker文档中:

RUN(该命令在shell-/bin/sh-c-shell中运行 (表格)


因此,当您运行luarocks安装时。

每个run命令都在自己的shell上运行,并提交一个新层

从Docker文档中:

RUN(该命令在shell-/bin/sh-c-shell中运行 (表格)


因此,当您运行luarocks安装时。

正如Alex da Silva所指出的,sourcing.bashrc发生在Dockerfile中的另一个shell中

您也可以尝试将Luarock命令与源代码bashrc在同一个shell中执行:

...
RUN source ~/.bashrc && luarocks install nngraph
RUN source ~/.bashrc && luarocks install optim
RUN source ~/.bashrc && luarocks install nn

RUN source ~/.bashrc && luarocks install cltorch
RUN source ~/.bashrc && luarocks install clnn

正如Alex da Silva指出的,sourcing.bashrc发生在Dockerfile的另一个shell中

您也可以尝试将Luarock命令与源代码bashrc在同一个shell中执行:

...
RUN source ~/.bashrc && luarocks install nngraph
RUN source ~/.bashrc && luarocks install optim
RUN source ~/.bashrc && luarocks install nn

RUN source ~/.bashrc && luarocks install cltorch
RUN source ~/.bashrc && luarocks install clnn